HTML emails are a engaging and generally work well for marketing emails.
They allow you to design emails that match your brand and give your readers a more visually engaging experience.
Majority of mail clients do not support HTML in emails and as such, it can be a pain designing HTML emails that render
properly on the recipients view.
While there are multiple services that can handle this task for you, you may want to do it your self if you value control and flexibility.
This section will guide you on how to achieve that.
Prerequisites
Linux distro e.g Ubuntu
Gmail (You may try other options)
a) Install mailutils
1 . Install mailutils from apt:
sudo apt install mailutils
2 . In the “General type of mail configuration:” prompt, choose “Internet Site” and press enter.
3 . A postfix configuration prompt will open. On the “System mail name:” prompt, enter gmail.com
b) Setup Gmail App Passwords
ssmtp will use your gmail account to send mail, but you can not use your normal gmail password with external applications. Gmail has a nifty feature called App passwords that lets you sign in to your Google Account from apps on devices that don’t support 2-Step Verification. Click here to set up App passwords. On the page, select ‘Mail’ under the ‘select app’ tab, then enter a custom name under the ‘select device’ tab.
Click on the ‘Generate’ button to generate the password. Just like your normal password, this app password grants complete access to your Google Account. Copy 16-character password shown, you will need it for the next step.
c) Install ssmtp
1 . Install ssmtp:
sudo apt-get install ssmtp
2 . Edit ssmtp.conf file:
sudo nano /etc/ssmtp/ssmtp.conf
Replace the placeholders (google_apps_password_here and your_account) with your details.
Your file should resemble this (your hostname will be different):
3 . Edit revaliases file:
sudo nano /etc/ssmtp/revaliases
Add this (remember to replace the place holder):
d) Create the HTML Template
Here’s an example of HTML email template. Notice that inline css was used, and that’s because mail clients will strip out all stylesheets except for inline styles.
1 . Copy this code and save it in a file called html_email_example.html:
You may save the file in home/Desktop.
e) Send the HTML Email
1 . Open the terminal and cd to the location of the html file. Send the file with the following command:
Replace user_name with your gmail account id.
The recepient should receive this email:
You could set this up on your server and have your apps automatically send info like news letters, welcome messages when users sign up etc.
It is worth notting that plain text may be better for personal contact and also remember to give people an option to use plain text when receiving your HTML emails.