Hello!

Faced the task of sending letters to customers, but with certain conditions.

  1. Send HTML by letter
  2. Send pictures contained in the letter along with the letter
  3. If possible, then CSS, so that all this is beautifully read.

Eventually:

  1. Resolved
  2. Not
  3. Not

Pictures, respectively, that in the html markup, should be taken from the attachment. Just somehow no one came across from familiar with this.

And maybe there is where or you yourself saw the rules for the design of html for letters.

  • Download RoundCube and rustle on the code! - Palmervan
  • Eheh ... tin ... well, crawling. just less code you want. picking up the finished big thing as usual is cruel. - Artem

2 answers 2

  1. -
  2. How to embed images in html email . If in brief, the attached images need to add a Content-ID header, and in HTML set cid:content-id-соответствующей-картинки to the image as src cid:content-id-соответствующей-картинки
  3. CSS in letters is prohibited.

An example of a letter with an attachment:

 To: Vasya <vasya@pupkin.ru> From: Example.Com <admin@example.com> Subject: Image Embedded Test Content-Type: multipart/related; boundary="=_5830a5e2a54f00a05267558b87c46967" Content-Transfer-Encoding: 8bit Content-Disposition: inline This is a message in Mime Format. If you see this, your mail reader does not support this format. --=_5830a5e2a54f00a05267558b87c46967 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <a href="http://example.com/"><img src="cid:5b2e7c4e0039fe369a8eb443139e8565"></a> <h1>Hello, Vasya!</h1> --=_5830a5e2a54f00a05267558b87c46967 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-ID: <5b2e7c4e0039fe369a8eb443139e8565> Content-Disposition: inline; filename="logo.gif" R0lGODlh2wBQANUAAMwAAOmMjNk4OPfOztYZGeJoaPG1td5RUfrm5tIQEO6lpdcqKtAICOZ7 ... далее base64 картинки pWiaDKgBOCACJ/CasAmbJDB1t3kuQQAAOw== --=_5830a5e2a54f00a05267558b87c46967-- 
  • It is Content-Type: multipart / related and pay attention to Content-ID: <5b2e7c4e0039fe369a8eb443139e8565> in the part of the letter with the picture. Exactly this should be a link from text / html. Frankly, I don’t know if there are any functions in PHP to form a letter, but with “hands” it is necessary to assemble such parts like this. This is from rfc2387, and the main rfc is on MIME 2045 and 2046. Most likely, I was late with this material (I hadn’t caught the question before), but suddenly it would be useful. - avp

How do I understand the pictures are embedded in the markup itself (in the html code)? If so, then simply in the src attribute, prescribe the full path, i.e. src='http://yoursite.com/..../yourimage.jpg' and of course the pictures will drag from your server. Well, with css also, just insert inline styles to tags, for example <p style='color:#222; font-weight:bold'></p> <p style='color:#222; font-weight:bold'></p> and then everything will be as you need.

  • I do not need to drag pictures from the server, I delete them from there after sending the letter, for I have to send 10K letters and each have 300KB of pictures, the server space is good. The question is not about taking pictures from the server, namely in attaching them to the letter. - Artem
  • So you need to delve here: phpclub.ru/detail/article/mail#part_2 - diezvl
  • no-no-no David Blaine no-no-no - Artem