Foros del Web » Programando para Internet » PHP »

Insertar imagen con phpmailer

Estas en el tema de Insertar imagen con phpmailer en el foro de PHP en Foros del Web. Estoy enviando un mensaje con phpmailer haciendo esto Código PHP: $body .= '<td width="39%"><img src="logo.png" width="170" height="72"></td>' ; $mail -> AddEmbeddedImage ( "logo.png" ,  "my-attach" ,  "logo.png" );  y ...
  #1 (permalink)  
Antiguo 28/05/2009, 17:15
Avatar de el_cesar  
Fecha de Ingreso: mayo-2001
Ubicación: Cali
Mensajes: 2.423
Antigüedad: 23 años
Puntos: 20
Insertar imagen con phpmailer

Estoy enviando un mensaje con phpmailer haciendo esto

Código PHP:
$body.='<td width="39%"><img src="logo.png" width="170" height="72"></td>';
$mail->AddEmbeddedImage("logo.png""my-attach""logo.png"); 
y tambien utilice
Código PHP:
$body'Embedded Image: <img alt="PHPMailer" src="cid:my-attach"> CRM Business'
pero no me envia en ninuno de los casos la imagen es decir el correo llega pero no se muestra la imagen pero esta si llega adjunta al mensaje
__________________
Say no more.......
  #2 (permalink)  
Antiguo 28/05/2009, 18:39
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Insertar imagen con phpmailer

Yo te sugiero que en vez de atachar una imagen hagas un link de ella y envies un mensaje que sea en HTML
<img src="http: / / tu_pagina_web.com/img.jpg" />

así aparece en el email
  #3 (permalink)  
Antiguo 29/05/2009, 12:19
Avatar de el_cesar  
Fecha de Ingreso: mayo-2001
Ubicación: Cali
Mensajes: 2.423
Antigüedad: 23 años
Puntos: 20
Respuesta: Insertar imagen con phpmailer

mmm nada lo puse asi
$body.='<td width="39%"><img src="http://www.crmbusiness.biz/cont234/recibos/logo.png" width="170" height="72"></td>';

y no funko
__________________
Say no more.......
  #4 (permalink)  
Antiguo 29/05/2009, 12:21
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Insertar imagen con phpmailer

que te sale en el email cuando tratas de ingresar esta linea?
  #5 (permalink)  
Antiguo 29/05/2009, 15:35
Avatar de el_cesar  
Fecha de Ingreso: mayo-2001
Ubicación: Cali
Mensajes: 2.423
Antigüedad: 23 años
Puntos: 20
Respuesta: Insertar imagen con phpmailer

me sale solo el cuadro de la imagen pero no sale la imagen
__________________
Say no more.......
  #6 (permalink)  
Antiguo 29/05/2009, 19:44
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Insertar imagen con phpmailer

Y si dieras right click para ver si salio la imagen en el codigo sale?

Porque si es así entiendo que falta enviar la parte del header que le dice al email que tambien reconozca html

seria algo así en el cuarto campo de mail()

$headers = "Content-type: text/html\r\n";
  #7 (permalink)  
Antiguo 30/05/2009, 10:13
Avatar de el_cesar  
Fecha de Ingreso: mayo-2001
Ubicación: Cali
Mensajes: 2.423
Antigüedad: 23 años
Puntos: 20
Respuesta: Insertar imagen con phpmailer

cuando le doy right click me sale esto http://www.crmbusiness.biz/cont234/recibos/logo.png


pero no entiendo muy bien donde deba insertar mi linea aqui pono mi script para ilustrar mejor el asunto

Código php:
Ver original
  1. //Se crea el formato de correo a Enviar
  2. $mail=new PHPMailer();
  3. $mail->Mailer="smtp";
  4. $mail->Helo = "www.crmbusiness.biz"; //Muy importante para que llegue a hotmail y otros
  5. $mail->SMTPAuth=true;
  6. $mail->Host="smtpout.secureserver.net";
  7. $mail->Port=80; //depende de lo que te indique tu ISP. El default es 25, pero nuestro ISP lo tiene puesto al 26
  8. $mail->Username="[email protected]";
  9. $mail->Password="buckdich";
  10. $mail->From="[email protected]";
  11. $mail->FromName="Comprobantes de Egreso";
  12. $mail->Timeout=60;
  13. $mail->IsHTML(true);
  14. //Enviamos el correo
  15. $mail->AddAddress('[email protected]'); //Puede ser Hotmail
  16. $mail->AddAddress('[email protected]'); //Puede ser Hotmail
  17. $mail->Subject='Comprobante de Egreso Numero '.$iderecibo.' Pagado a '.$pagadoa.'';
  18.  
  19. //Cuerpo del Mensaje
  20. $body ='<table width="900" border="0" cellpadding="0" cellspacing="0">';
  21. $body.='<tr>';
  22. $body.='<td><table width="100%" border="0">';
  23. $body.='<tr>';
  24. $body.='<td width="39%"><img src="http://www.crmbusiness.biz/cont234/recibos/logo.png" width="170" height="72"></td>';
  25. $body.='<td width="61%"><table width="100%" border="1">';
  26. $body.='<tr>';
  27. $body.='<td><strong>COMPROBANTE DE EGRESO N&deg;</strong></td>';
  28. $body.='<td><font color="#FF0000">000'.$iderecibo.'</font></td>';
  29. $body.='</tr>';
  30. $body.='</table></td>';
  31. $body.='</tr>';
  32. $body.='</table></td>';
  33. $body.='</tr>';
  34. $body.='<tr>';
  35. $body.='<td><table width="100%" border="1">';
  36. $body.='<tr>';
  37. $body.='<td width="8%"><strong>CIUDAD:</strong></td>';
  38. $body.='<td width="24%">'.$ciudad.'</td>';
  39. $body.='<td width="8%"><strong>FECHA:</strong></td>';
  40. $body.='<td width="24%">'.$fecha.'</td>';
  41. $body.='<td width="14%"><div align="right"><strong>VALOR:</strong></div></td>';
  42. $body.='<td width="22%">'.$monto.'</td>';
  43. $body.='</tr>';
  44. $body.='</table></td>';
  45. $body.='</tr>';
  46. $body.='<tr>';
  47. $body.='<td><table width="100%" border="1">';
  48. $body.='<tr>';
  49. $body.='<td width="19%"><strong>PAGADO A:</strong></td>';
  50. $body.='<td width="81%">'.$pagadoa.'</td>';
  51. $body.='</tr>';
  52. $body.='</table></td>';
  53. $body.='</tr>';
  54. $body.='<tr>';
  55. $body.='<td><table width="100%" border="1">';
  56. $body.='<tr>';
  57. $body.='<td width="19%"><strong>POR CONCEPTO DE:</strong></td>';
  58. $body.='<td width="81%">'.$concepto.'</td>';
  59. $body.='</tr>';
  60. $body.='</table></td>';
  61. $body.='</tr>';
  62. $body.='<tr>';
  63. $body.='<td><table width="100%" border="1">';
  64. $body.='<tr>';
  65. $body.='<td width="19%"><strong>LA SUMA DE:</strong></td>';
  66. $body.='<td width="81%">'.$valor_letras.'</td>';
  67. $body.='</tr>';
  68. $body.='</table></td>';
  69. $body.='</tr>';
  70. $body.='<tr>';
  71. $body.='<td><table width="100%" border="0">';
  72. $body.='<tr>';
  73. $body.='<td><div align="center"><strong>CONTABILIZACION</strong></div></td>';
  74. $body.='<td><table width="100%" border="1">';
  75. $body.='<tr>';
  76. $body.='<td><strong>EFECTIVO</strong></td>';
  77. $body.='<td>'.$monto1.'</td>';
  78. $body.='</tr>';
  79. $body.='</table></td>';
  80. $body.='</tr>';
  81. $body.='<tr>';
  82. $body.='<td width="75%"><table width="100%" border="1">';
  83. $body.='<tr>';
  84. $body.='<td width="25%"><div align="center"><strong>C&oacute;digo P.U.C.</strong></div></td>';
  85. $body.='<td width="35%"><div align="center"><strong>Cuenta</strong></div></td>';
  86. $body.='<td width="20%"><div align="center"><strong>D&eacute;bitos</strong></div></td>';
  87. $body.='<td width="20%"><div align="center"><strong>Cr&eacute;ditos</strong></div></td>';
  88. $body.='</tr>';
  89. $body.='<tr>';
  90. $body.='<td>&nbsp;</td>';
  91. $body.='<td>&nbsp;</td>';
  92. $body.='<td>&nbsp;</td>';
  93. $body.='<td>&nbsp;</td>';
  94. $body.='</tr>';
  95. $body.='<tr>';
  96. $body.='<td>&nbsp;</td>';
  97. $body.='<td>&nbsp;</td>';
  98. $body.='<td>&nbsp;</td>';
  99. $body.='<td>&nbsp;</td>';
  100. $body.='</tr>';
  101. $body.='<tr>';
  102. $body.='<td>&nbsp;</td>';
  103. $body.='<td>&nbsp;</td>';
  104. $body.='<td>&nbsp;</td>';
  105. $body.='<td>&nbsp;</td>';
  106. $body.='</tr>';
  107. $body.='<tr>';
  108. $body.='<td>&nbsp;</td>';
  109. $body.='<td>&nbsp;</td>';
  110. $body.='<td>&nbsp;</td>';
  111. $body.='<td>&nbsp;</td>';
  112. $body.='</tr>';
  113. $body.='<tr>';
  114. $body.='<td>&nbsp;</td>';
  115. $body.='<td>&nbsp;</td>';
  116. $body.='<td>&nbsp;</td>';
  117. $body.='<td>&nbsp;</td>';
  118. $body.='</tr>';
  119. $body.='</table></td>';
  120. $body.='<td width="25%"><table width="100%" border="1">';
  121. $body.='<tr>';
  122. $body.='<td><div align="center"><strong>CHEQUE N&deg;.</strong></div></td>';
  123. $body.='</tr>';
  124. $body.='<tr>';
  125. $body.='<td>'.$cheque.'</td>';
  126. $body.='</tr>';
  127. $body.='<tr>';
  128. $body.='<td><div align="center"><strong>BANCO</strong></div></td>';
  129. $body.='</tr>';
  130. $body.='<tr>';
  131. $body.='<td>'.$banco_cheque.'</td>';
  132. $body.='</tr>';
  133. $body.='<tr>';
  134. $body.='<td><div align="center"><strong>SUCURSAL</strong></div></td>';
  135. $body.='</tr>';
  136. $body.='<tr>';
  137. $body.='<td>'.$sucursal.'></td>';
  138. $body.='</tr>';
  139. $body.='</table></td>';
  140. $body.='</tr>';
  141. $body.='</table></td>';
  142. $body.='</tr>';
  143. $body.='<tr>';
  144. $body.='<td><table width="100%" border="1">';
  145. $body.='<tr>';
  146. $body.='<td width="18%"><div align="center"><strong>ELABORADO POR:</strong></div></td>';
  147. $body.='<td width="17%"><strong>APROBRADO POR:</strong></td>';
  148. $body.='<td width="21%"><strong>CONTABILIZADO POR:</strong></td>';
  149. $body.='<td width="44%"><strong>RECIBI CONFORME</strong></td>';
  150. $body.='</tr>';
  151. $body.='<tr>';
  152. $body.='<td>&nbsp;</td>';
  153. $body.='<td rowspan="2">&nbsp;</td>';
  154. $body.='<td rowspan="2">&nbsp;</td>';
  155. $body.='<td><p>&nbsp;</p>';
  156. $body.='<p>&nbsp;</p>';
  157. $body.='<p>&nbsp;</p></td>';
  158. $body.='</tr>';
  159. $body.='<tr>';
  160. $body.='<td><p>'.$elaboro.'</p>';
  161. $body.='<p>&nbsp;</p></td>';
  162. $body.='<td><table width="100%">';
  163. $body.='<tr>';
  164. $body.='<td>'.$pagadoa.'</td>';
  165. $body.='</tr>';
  166. $body.='<tr>';
  167. $body.='<td><strong>C.C.</strong></td>';
  168. $body.='</tr>';
  169. $body.='</table></td>';
  170. $body.='</tr>';
  171. $body.='<td colspan="4" ><strong>AVENIDA 3A Norte # 24 N 24<br>';
  172. $body.='Tel&eacute;fono: 485 4564<br>';
  173. $body.='CALI – COLOMBIA<br>';
  174. $body.='</strong></td>';
  175. $body.='</table></td>';
  176. $body.='</tr>';
  177. $body.='</table>';
  178.  
  179.  
  180. //SE ENVIA EL MENSAJE
  181. $mail->Body = $body;
  182. $mail->AddEmbeddedImage("logo.png", "my-attach", "logo.png");
  183. //$mail->Body = 'Embedded Image: <img alt="PHPMailer" src="cid:my-attach"> Here is an image!';  
  184. $mail->Send();
__________________
Say no more.......
  #8 (permalink)  
Antiguo 30/05/2009, 10:45
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Insertar imagen con phpmailer

por el momento quitale

$mail->AddEmbeddedImage("logo.png", "my-attach", "logo.png");

y añade en el $body una linea que diga
Código PHP:
$body.="<img src='http://www.crmbusiness.biz/cont234/recibos/logo.png' border='0' />"
Otra cosa te sugiero que en vez de estar escribiendo

Código PHP:
$body .= "....";
$body .= "....";
$body .= "....";
$body .= "....";
$body .= "...."
hagas esto

Código PHP:
$body "Escribir codigo
seguir escribiendo
añades otro
<table>
<tr>
<td></td>
</tr>
</table>"

Me dejas saber
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:49.