Send image that is on the server as an email attachment

Asked

Viewed 418 times

1

I need to send an email with Folder’s (images) that are already on the server. Does anyone have an idea how to do that? The e-mail is already working. I’m using codeigniter and phpmailer.

  • You can set Phpmailer to HTML, and then you send the link to the images in a <img> tag or, if you don’t want to display the image, you put the link in a <a> tag and arrow the download attribute, so: <a href="your image" download > Download Image </a>

  • You want the image to be added to the body of the email or as an attachment to it?

2 answers

1

Solved, added this line:

$mail->AddAttachment("caminho_da_imagem/imagem.png");

1

There are some ways.

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

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

There is also the possibility to add the image with 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 attached image id:

<img src='cid:teste'>

Abs

Browser other questions tagged

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