HomeProgrammingHow to send HTML Mail to a Mailing List

How to send HTML Mail to a Mailing List


Many stores use GNU Mailman to maintain a mailing list for store sales and newsletters. Satchmo has this as a built-in option, for example. It isn’t too bad an option, after all. You can easily set options so that it is “push only” and therefore only the mailing list owner can send mail.

(Yes, it really isn’t a great idea. I heartily recommend a service such as Aweber to manage your list, which will lead to much better legal compliance and more professional results. But bear with me, not all store owners want to pay for additional services.)

However, what if you want to send nicely formatted HMTL newsletters? How do you get your mail client to send those so that they’ll look nice for your customers? Answer, you don’t. You send it manually from the commandline.

Here’s how…

Go to the server where you’ve got your store. Hopefully it is linux or similar. I couldn’t care less about how to do this from Windows. Not my bag.

Make a well-formatted email and put it on the server somewhere. In this example, we’ll call it “newsletter.html”

Now copy and modify this for your own needs.

echo "From: you@example.com"
echo "To: yourlist@example.com"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed;"
echo ' boundary="PAA08673.1018277622/example.com"'
echo "Subject: My Newsletter"
echo ""
echo "This is a MIME-encapsulated message"
echo ""
echo "--PAA08673.1018277622/example.com"
echo "Content-Type: text/html"
echo ""
cat newsletter.html
echo ""
echo "--PAA08673.1018277622/example.com"
) | /usr/sbin/sendmail -t

Paste that into your commandline, and you’ll send that HMTL email, formatted “raw”, just the way you want it.


I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.


Sorry, the comment form is closed at this time.