php - SwiftMailer attach image in email body -


basically use yii2 mailer, in principe, use swifmailer. so, want display image in body email.

our user use mozilla thunderbird no problem. , in user use email client based microsoft such oe, ms. oe 2007, 2010, 2013 , windows live mail, image displayed attached file. in body email displayed big cross icon. code :

 $mail = yii::$app->mailer->compose();         $mail->embed($img,[             'filename' => 'request.png',             'contenttype' => 'image/png'         ]);         $arrayto = array("dzil@tresnamuda.co.id");         $mail->setfrom(array("itjkt@tresnamuda.co.id" => "tms it-jkt system"))                 ->setto($arrayto)                 ->setcc(array('dziljalal1@gmail.com'/* , \yii::$app->user->identity->email */))                 ->setsubject("david - $status request sudah terkonfirmasi ke dept. dari user : " . yii::$app->user->identity->username)                 ->sethtmlbody("kepada yth. bapak david v lengkong, <br>dengan hormat, <br>                                 dengan ini kami lampirkan data request permintaan dan perbakan sebagai berikut. <br>                                  <img src='$img' alt='image'>");         $mail->send(); 

email client

updated image has formatted data:image/png;base64,

please advise.

try this:

$mail = yii::$app->mailer->compose('embed-email', ['imagefilename' => 'request.png']); 

and in view:

<img src="<?= $mail->embed($imagefilename); ?>"> 

source.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -