Send image that is on the server as email attachment

I need to send an email with folder's (images) that are already on the server. Does anyone have an idea how to do this? Sending the email is already working. I am using codeigniter and phpmailer.

Author: Tmc, 2017-10-19

2 answers

There are some ways.

The first is to have the image a public server path and only use the tag:

<img src="caminho/absoluto/imagem.png" />

There is also the possibility to add the image with the PHPMailer itself using the method AddEmbeddedImage

Http://phpmailer.github.io/PHPMailer/classes/PHPMailer.PHPMailer.PHPMailer.html#method_addEmbeddedImage

$mail->AddEmbeddedImage('img/error.png', 'teste');

If I'm not mistaken you need to put a tag with the image id attached:

<img src='cid:teste'>

Abs

 1
Author: Eduardo Abreu dos Santos, 2017-10-19 15:03:07

Solved , I added this line:

$mail->AddAttachment("caminho_da_imagem/imagem.png");
 1
Author: Fernando Ricardo, 2017-10-20 15:37:29