How to create an email with embedded images that is compatible with the most mail clients

I’ve had success with exactly the same headers as you’re using, with the following differences: Embedded is not a valid value for the Content-Disposition header. attachment should be fine. inline should also be fine, though I’ve usually seen attachment for multipart/related embedded images. The value of the Content-ID header is supposed to be in the … Read more

How can I get an email message’s text content using Python?

In a multipart e-mail, email.message.Message.get_payload() returns a list with one item for each part. The easiest way is to walk the message and get the payload on each part: import email msg = email.message_from_string(raw_message) for part in msg.walk(): # each part is a either non-multipart, or another multipart message # that contains further parts… Message … Read more

Email from PHP has broken Subject header encoding

Update   For a more practical and up-to-date answer, have a look at Palec’s answer. The specified character encoding in Content-Type does only describe the character encoding of the message body but not the header. You need to use the encoded-word syntax with either the quoted-printable encoding or the Base64 encoding: encoded-word = “=?” charset “?” encoding … Read more

What are the “parts” in a multipart email?

An email message consists of a single MIME part, or a multipart structure with multiple MIME parts. If there is no multipart structure, the message is compatible with pre-MIME RFC822 messages, and the Content-type: etc headers are optional (if you don’t spell out a content type and encoding, Content-type: text/plain; charset=”us-ascii” and Content-transfer-encoding: 7bit are … Read more

I need my PHP page to show my BLOB image from mysql database

In your current case, you have two upfront options. The first, and the one I don’t recommend if you have numerous images like this, is to use inline base64 encoding. This is done with: <img src=”data:image/jpeg;base64,<?php echo base64_encode($image); ?>” /> A copy/paste version, using your existing code: echo ‘<dt><strong>Technician Image:</strong></dt><dd>’ . ‘<img src=”data:image/jpeg;base64,’ . base64_encode($row2[‘image’]) … Read more

Get MIME type from filename extension

For ASP.NET or other The options were changed a bit in ASP.NET Core, here they are (credits): new FileExtensionContentTypeProvider().TryGetContentType(fileName, out contentType); (vNext only) Never tested, but looks like you can officially expand the mime types list via the exposed Mappings property. Use the MimeTypes NuGet package Copy the MimeMappings file from the reference source of … Read more