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();
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); ?>">
Comments
Post a Comment