M
M
MastaEx2010-09-30 09:50:13
CMS
MastaEx, 2010-09-30 09:50:13

An unknown way to insert inline pictures into emails?

f190d226.png
I received a newsletter on gmail the other day and saw the pictures right away, without any “Show pictures” there, and for some reason I looked at the source. I thought that there was a regular attachment with Content-Disposition: inline and links to it in the body of the letter. But I saw something different. Attached pictures were formatted like this:

copy source  | Copy HTML
Content-Type: image/jpeg; name=image.jpg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=image.jpg
Content-Location: example.com/image.jpg
 

And in the body of the letter there were just <img src=" example.com/image.jpg "> tags.
I tried to reproduce using SwiftMailer:
copy source  | Copy HTML
$transport = Swift_SmtpTransport::newInstance();
$transport->setUsername('login');
$transport->setPassword('password');
 
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setSubject('Hello man!');
$message->setFrom(array('[email protected]'=>'R2D2'));
$message->setTo('[email protected]', 'C3PO');
 
$body='<img src=" example.com/image.jpg ">';
$message->setBody($body, 'text/html');
 
$attach=Swift_Attachment::fromPath('/home/example/htdocs/image.jpg');
example.com/image.jpg ');
 
$message->attach($attach);
$mailer->send($message);
 

It works, pictures are loaded into the letter immediately, they are not requested from the server, as attachments are not shown. I checked in gmail and outlook 2007. I looked through all the rfc that I found - I didn’t see any mention of this anywhere. According to rfc , to insert an inline image, you need to use Content-Disposition: inline and Content-ID
Question: why does this work?
By the way, did gmail always show inline pictures right away?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mithgol, 2010-09-30
@Mithgol

This is from RFC 2616, subsection 14.14 .

M
MastaEx, 2010-09-30
@MastaEx

But this is rfc over HTTP, I don’t understand how it is connected with letters?
And in HTTP, from what I read, I can’t understand how this header is used. Can you give an example?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question