Image in HTML e-mail in Phpmailer

Asked

Viewed 942 times

0

I’m making a template for sending email marketing, which contains an image:

<tr>
   <td style="padding: 10px 0 10px 0;" align="center" bgcolor="#1ac6ff">
      <img src="templates/email/logo.png" alt="Ticket" style="display: inline; padding: 0 20px 0 20px;" height="auto" width="auto" />
   </td>
</tr>

But the image does not go to the email (of course, it is with local address).

For PHPMailer, there is a way to "attach" the image together to use it or I will have to upload it to an image service ?

The problem in case of image server, would this link go out of air one day, and so lose all previous emails, correct !?

  • I was gonna suggest a Base64, but it looks like Gmail won’t take it. If you are interested in taking a look here https://stackoverflow.com/questions/16242489/send-a-base64-image-in-html-email

  • I found this: https://stackoverflow.com/questions/3708153/send-email-with-phpmailer-embed-image-in-body, but it’s not working... I’m checking ! rs Thanks

  • But here’s the deal $mail->AddEmbeddedImage

  • For this is the way!

1 answer

2


Using the method $mail->AddEmbeddedImage:

$mail->AddEmbeddedImage('img/logo.jpg', 'logo_ref');

Tag <img> inserts: src='cid:logo_ref'.

This way, the image will be embedded in the email.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.