[GH-ISSUE #129] Improve Documentation to show how to send an HTML format file as an email #85

Closed
opened 2026-03-15 12:28:29 +03:00 by kerem · 6 comments
Owner

Originally created by @maza256 on GitHub (Jun 24, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/129

The documentation currently only shows how to send a plain text email. It would be wonderful if it could be used to send a fully formatted HTML file.

Originally created by @maza256 on GitHub (Jun 24, 2023). Original GitHub issue: https://github.com/axllent/mailpit/issues/129 The documentation currently only shows how to send a plain text email. It would be wonderful if it could be used to send a fully formatted HTML file.
kerem closed this issue 2026-03-15 12:28:34 +03:00
Author
Owner

@axllent commented on GitHub (Jun 25, 2023):

The example in the documentation is purely intended to briefly test whether sendmail & Mailpit is working. Fully formatted HTML emails are typically not sent from the commandline, but rather send via applications using (for example) PHP, Ruby, Java, Go, etc which often then use sendmail to relay the message. This falls completely outside of the scope of Mailpit and/or the documentation.

If you do specifically wish so send an HTML email via the commandline, a simple Google search returns the following example:

echo "From: me@xyz.com
To: them@xyz.com
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary='PAA08673.1018277622/server.xyz.com'
Subject: Test HTML e-mail.

This is a MIME-encapsulated message

--PAA08673.1018277622/server.xyz.com
Content-Type: text/html

<html> 
<head>
<title>HTML E-mail</title>
</head>
<body>
<a href='http://www.google.com'>Click Here</a>
</body>
</html>
--PAA08673.1018277622/server.xyz.com
" | sendmail -t
<!-- gh-comment-id:1605827177 --> @axllent commented on GitHub (Jun 25, 2023): The example in the documentation is purely intended to briefly test whether sendmail & Mailpit is working. Fully formatted HTML emails are typically not sent from the commandline, but rather send via applications using (for example) PHP, Ruby, Java, Go, etc which often then use sendmail to relay the message. This falls completely outside of the scope of Mailpit and/or the documentation. If you do specifically wish so send an HTML email via the commandline, a simple Google search returns the following example: ```shell echo "From: me@xyz.com To: them@xyz.com MIME-Version: 1.0 Content-Type: multipart/alternative; boundary='PAA08673.1018277622/server.xyz.com' Subject: Test HTML e-mail. This is a MIME-encapsulated message --PAA08673.1018277622/server.xyz.com Content-Type: text/html <html> <head> <title>HTML E-mail</title> </head> <body> <a href='http://www.google.com'>Click Here</a> </body> </html> --PAA08673.1018277622/server.xyz.com " | sendmail -t ```
Author
Owner

@ilhamsyahids commented on GitHub (Mar 22, 2025):

Hello @axllent

I'm trying to send email with multipart/alternative like as you do, however it appear as Text in web ui and not showing anything, I use latest axllent/mailpit:v1.23 and with only config MP_SMTP_AUTH_ACCEPT_ANY, MP_SMTP_AUTH_ALLOW_INSECURE. Can you help me for this?

Thanks

Image
<!-- gh-comment-id:2745205945 --> @ilhamsyahids commented on GitHub (Mar 22, 2025): Hello @axllent I'm trying to send email with `multipart/alternative` like as you do, however it appear as Text in web ui and not showing anything, I use latest `axllent/mailpit:v1.23` and with only config `MP_SMTP_AUTH_ACCEPT_ANY`, `MP_SMTP_AUTH_ALLOW_INSECURE`. Can you help me for this? Thanks <img width="408" alt="Image" src="https://github.com/user-attachments/assets/130610e1-8cef-4d2d-bcaa-370430f96dd6" />
Author
Owner

@axllent commented on GitHub (Mar 22, 2025):

@ilhamsyahids That would be because that example does not contain a text part. Try something like this:

echo "From: Example Company <news@example.com>
To: Joe User <joe.u@example.net>
Date: Sat, 21 May 2011 17:40:11 +0300
Subject: Multipart message example
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=asdfghjkl

--asdfghjkl
Content-Type: text/plain; charset=utf-8

This is the text part.

--asdfghjkl
Content-Type: text/html; charset=utf-8

<body>
This is the <b>HTML</b> part.
</body>

--asdfghjkl--
" | sendmail -t
<!-- gh-comment-id:2745213829 --> @axllent commented on GitHub (Mar 22, 2025): @ilhamsyahids That would be because that example does not contain a text part. Try something like this: ```shell echo "From: Example Company <news@example.com> To: Joe User <joe.u@example.net> Date: Sat, 21 May 2011 17:40:11 +0300 Subject: Multipart message example MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=asdfghjkl --asdfghjkl Content-Type: text/plain; charset=utf-8 This is the text part. --asdfghjkl Content-Type: text/html; charset=utf-8 <body> This is the <b>HTML</b> part. </body> --asdfghjkl-- " | sendmail -t ```
Author
Owner

@ilhamsyahids commented on GitHub (Mar 22, 2025):

I see, I know the issue was. Apparently, mailpit cannot detect it html and text part if the the boundary has <>, please see the image below:

Image
echo "From: Example Company <news@example.com>
To: Joe User <joe.u@example.net>
Date: Sat, 21 May 2011 17:40:11 +0300
Subject: Multipart message example
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=MIME_boundary_<asdfghjkl@example.net>

--MIME_boundary_<asdfghjkl@example.net>
Content-Type: text/plain; charset=utf-8

This is the text part.

--MIME_boundary_<asdfghjkl@example.net>
Content-Type: text/html; charset=utf-8

<body>
This is the <b>HTML</b> part.
</body>

--MIME_boundary_<asdfghjkl@example.net>--
" | mailpit sendmail -t

I also tried when its not contain the prefix (boundary=<asdfghjkl@example.net>), the result was email not appear in the mailpit.

I confirmed in gmail, both are works:

Image Image

Can you confirm on your end? @axllent

<!-- gh-comment-id:2745304637 --> @ilhamsyahids commented on GitHub (Mar 22, 2025): I see, I know the issue was. Apparently, mailpit cannot detect it html and text part if the the boundary has `<>`, please see the image below: <img width="617" alt="Image" src="https://github.com/user-attachments/assets/1fdea204-1b7f-42e4-aee2-1837b385f274" /> ```sh echo "From: Example Company <news@example.com> To: Joe User <joe.u@example.net> Date: Sat, 21 May 2011 17:40:11 +0300 Subject: Multipart message example MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=MIME_boundary_<asdfghjkl@example.net> --MIME_boundary_<asdfghjkl@example.net> Content-Type: text/plain; charset=utf-8 This is the text part. --MIME_boundary_<asdfghjkl@example.net> Content-Type: text/html; charset=utf-8 <body> This is the <b>HTML</b> part. </body> --MIME_boundary_<asdfghjkl@example.net>-- " | mailpit sendmail -t ``` I also tried when its not contain the prefix (`boundary=<asdfghjkl@example.net>`), the result was email not appear in the mailpit. I confirmed in gmail, both are works: <img width="528" alt="Image" src="https://github.com/user-attachments/assets/a4c3a95e-ea4d-4fc2-bfba-3812dd12ce94" /> <img width="697" alt="Image" src="https://github.com/user-attachments/assets/420d0970-b3c8-402d-8eca-2355b9a75fac" /> Can you confirm on your end? @axllent
Author
Owner

@axllent commented on GitHub (Mar 22, 2025):

@ilhamsyahids I would suggest that it is because you're using invalid characters. I don't think< & > are legally allowed. See https://stackoverflow.com/a/147467

<!-- gh-comment-id:2745409202 --> @axllent commented on GitHub (Mar 22, 2025): @ilhamsyahids I would suggest that it is because you're using invalid characters. I don't think`<` & `>` are legally allowed. See https://stackoverflow.com/a/147467
Author
Owner

@ilhamsyahids commented on GitHub (Mar 25, 2025):

Thats make sense, thanks for your confirmation @axllent

<!-- gh-comment-id:2749957318 --> @ilhamsyahids commented on GitHub (Mar 25, 2025): Thats make sense, thanks for your confirmation @axllent
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#85
No description provided.