views:

112

answers:

3

Hi.

I'm trying to send HTML mail, with PHPMailer, with images. The body is loaded from a html file, that contains all the info.

When sending the mail, the image does not appear in the body, although I even send the image also as an attachment.

HTML <img> tag points to the same place as the place.

PHP:

$mail->AddAttachment('img/2u_cs_mini.jpg');

How can I make the html point to the attachment so the image can be loaded in the body.

Looking at the example that comes with PHPMailer I do not notice any difference, and in their case the image does appear.

A: 

It's customary to host the images on your server and link to them remotely. This (IIRC) saves the email infrastructure from having to deal with a lot of big attachments.

I'm sure it's possible to link to an attachment, but it's not the most common approach.

Tom Wright
I would prefer to link to the attachment, because in this case it would make so sense then to send the attachment.
elvispt
It is customary, but is also a problem since linking to images can be used to track opening of the message (so privacy issues) and lot of users will have the option to show linked images off, where inline/embedded images will be on by default.
Unreason
A: 

I suggest you to link image source with full path like:

http://www.example.com/img/2u_cs_mini.jpg

fabrik
+1  A: 

I found the answer:

$mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u');

and on the <img> tag put src='cid:logo_2u\'

elvispt