HTML email image in PHPMailer

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 has a local address).

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

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

    
asked by anonymous 26.03.2018 / 14:10

1 answer

1

Using the $mail->AddEmbeddedImage method:

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

In the <img> tag it inserts: src='cid:logo_ref' .

In this way, the image will be embedded in the email.

    
26.03.2018 / 14:30