Alternatively, you can check nodemailer on npm. This is a great package: easy to use and extensive documentation. With nodemailer you can do something like this
var nodemailer = require('nodemailer'); var transport = nodemailer.createTransport({ host: 'smtp.mailgun.org', port: 587, secure: false, tls: { ciphers: 'SSLv3' }, auth: { user: '<Mailgun SMTP login>', password: 'password' } }); transport.sendMail({ from: '<Mailgun SMTP login>', to: [' bob@example.com ', ' bill@foobarbaz.com ', ], subject: 'Fancy Email', text: 'still send some text to be on the safe side', html: { path: 'path/to/email.html' } }, callback)
However, I would recommend being very thorough in your html email design. Email html is very different from html on the web. There is a much wider variety of email clients that will do your html differently, and some, like Outlook for Windows and gmail, will not handle your html very well. Litmus contains several useful resources regarding best practices for designing html messages.
My suggestion would be to use a writing base for your style, use inky to simplify the semantics of writing the html email address and inline-css to embed all your styles. Even if you use alternative methods of sending mail, check out these resources to develop it. They will save you a lot of headache.
source share