ete aqui... que tengo que hacerlo dinamico... para que tome N cantidad de imagenes...
hice algo asi.. (la funcion htmlspecialchars_decode la saque de los comentarios de la documentacion oficial como alternativa para el php < 5... )
Código PHP:
session_start();
if (!function_exists('htmlspecialchars_decode')) {
function htmlspecialchars_decode($str, $options="") {
$trans = get_html_translation_table(HTML_SPECIALCHARS);
$decode = ARRAY();
foreach ($trans AS $char=>$entity) {
$decode[$entity] = $char;
}
$str = strtr($str, $decode);
return $str;
}
}
require("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->PluginDir = "phpmailer/";
$mail->Mailer = "smtp";
$mail->Host = "smtp.nada.com.ar";
$mail->SMTPAuth = true;
$mail->Username = "lala";
$mail->Password = "lelo";
$mail->From = "yo";
$mail->FromName = "DjFaramir";
$mail->Timeout=90;
$mail->IsHTML(true);
$texto=$_SESSION["cuerpo"];
$partes=split("src=",$texto);
$cuantas=count($partes);
for ($a=0;$a<$cuantas;$a++){
$parte=$partes[$a];
$imagen=explode('"',$parte);
$name=explode("/",$imagen[1]);
if(count($name)!=1){
$cant=count($name);
$foto=$name[$cant-1];
$cadena="";
for ($b=1;$b<$cant;$b++){
if ($b==2){
$cadena=$name[$b];
}else{
$cadena.="/".$name[$b];
}
}
echo $cadena;
$imagen[1]=$cadena;
$mail->AddEmbeddedImage($imagen[1],"img-cod".$a,$a.".jpg");
$imagen[1]="cid:img-cod".$a;
$partes[$a]=implode('"',$imagen);
}
};
$texto=implode("scr=",$partes);
$direccion=$campos["email"];
$mail->AddAddress("[email protected]");
$mail->Body = htmlspecialchars_decode($texto);
$mail->AltBody = "Mensaje de prueba mandado con phpmailer en formato solo texto";
$exito = $mail->Send();
el html que obtengo despues de tanto procedimiento es este para un ejemplo de 3 imagenes...
Código HTML:
<img scr="cid:img-cod1" alt="" height="12" width="22">sdfsdfsdfsd<br> sdfsdfsdfssdf<br> fsdf<br> sdf<img scr="cid:img-cod2" alt="" height="300" width="300"><br> sdf<br> sdf<br> <img scr="cid:img-cod3" alt="" height="100" width="765">sdfsdfsdfsdf
Código HTML:
<img alt="" height="12" width="22">sdfsdfsdfsd<br> sdfsdfsdfssdf<br> fsdf<br> sdf<img alt="" height="300" width="300"><br> sdf<br> sdf<br> <img alt="" height="100" width="765">sdfsdfsdfsdf
Código HTML:
<img width="22" height="12" scr="cid:img-cod1" alt="" />sdfsdfsdfsd<br /> sdfsdfsdfssdf<br /> fsdf<br /> sdf<img width="300" height="300" scr="cid:img-cod2" alt="" /><br /> sdf<br /> sdf<br /> <img width="765" height="100" scr="cid:img-cod3" alt="" />sdfsdfsdfsdf
Código HTML:
Content-Type: application/octet-stream; name="1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <img-cod1>
Content-Disposition: inline; filename="1.jpg"
si alguien me ilumina... desde ya muchas gracias :P