How do I display images embedded in HTML emails?

I need to send an email containing the image and text around it. I can already send an HTML letter, attach the image using Content-ID: <Picture.jpg> , and then specify it as <img src="cid:Picture.jpg" alt="" /> . Cute

The problem is that many email clients do not display it by default . For example, GMail by default only displays images from senders to whom you sent at least two emails. I have no idea about Mozilla Thunderbird, but judging by the complaint of the client, he does something similar - the image is displayed as an attachment and does not appear in the body of the message.

What am I doing wrong / can do better?

Here is a [censored] copy of the letter:

 Delivered-To: [censored] Received: by 10.204.187.8 with SMTP id cu8cs411179bkb; Wed, 4 Jan 2012 05:36:05 -0800 (PST) Received: by 10.152.106.45 with SMTP id gr13mr25346083lab.9.1325684164222; Wed, 04 Jan 2012 05:36:04 -0800 (PST) Return-Path: <[censored]> Received: from [censored] ([censored]. [[censored]]) by mx.google.com with ESMTPS id nq10si44421925lab.26.2012.01.04.05.36.03 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jan 2012 05:36:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of [censored] designates [censored] as permitted sender) client-ip=[censored]; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of [censored] designates [censored] as permitted sender) smtp.mail=[censored] Received: from [censored] ([censored]) by [censored] ([censored]) with Microsoft SMTP Server id 8.1.436.0; Wed, 4 Jan 2012 15:36:03 +0200 MIME-Version: 1.0 From: [censored] To: [censored] Date: Wed, 4 Jan 2012 15:36:02 +0200 Subject: Test Content-Type: multipart/mixed; boundary="--boundary_1_5d3b21f4-0e5d-4727-a2a2-a49bb2ad5062" Message-ID: < e42be75d-53b2-46c7-a1c6-150c95b86ba6@ [censored]> Return-Path: [censored] ----boundary_1_5d3b21f4-0e5d-4727-a2a2-a49bb2ad5062 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: base64 [snip base64 encoded HTML] ----boundary_1_5d3b21f4-0e5d-4727-a2a2-a49bb2ad5062 Content-Type: image/jpeg; name="Picture.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment Content-ID: <Picture.jpg> [snip base64 encoded JPEG] ----boundary_1_5d3b21f4-0e5d-4727-a2a2-a49bb2ad5062-- 

Added:. For downvoters - although I see the potential for misuse in this matter, the truth is that this is from a legitimate scenario. I am making a website for a web store for a stationery provider. The client wants the "send email" button on the product page so that visitors can send interesting product descriptions to their friends / bosses / independently. I am trying to include a product image in an email. The customer complains that the image is not displayed.

+4
source share
3 answers

Most email clients will always hide images in the body of an html message if it is not sent from a trusted sender. Think about it, if any spam site was supposed to send you non-localized images, do you want them to pop up when you open an email?

The only thing you can do is ask recipients to select an option in the email to always show images from this sender. Also, from my experience, often images are not sent as an email attachment, but instead the image tag points to an image posted by the sender.

+1
source

Copied from this answer :

The value of the Content-ID header must be in the same format as the message identifier , which, in turn, is very similar to the email address . < Picture.jpg@yourmailer > is more likely to work with most email programs.

+2
source

I do not think that you can force email clients to display emails in a certain way. Just think about the security issues that this will impose!
Perhaps you can find out what parameters to configure in the client client and recommend it to him.

+1
source

Source: https://habr.com/ru/post/1390236/


All Articles