Run a Simple SMTP server locally for Mac users
- Install MailHog
$ brew install mailhog
$ brew services start mailhog
$ open http://127.0.0.1:80252. Config postfix
$ sudo vi /etc/postfix/main.cf
# Add this at the bottom for MailHog
myhostname = localhost
relayhost = [localhost]:1025
$ sudo postfix stop && sudo postfix start3. Send Mail
$ date | mail -s "Test Email" [email protected]Or. with NodeJS
const nodemailer = require('nodemailer');
async function main() {
let transporter = nodemailer.createTransport({
host: 'localhost',
port: 25,
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '[email protected]', // sender address
to: '[email protected]', // list of receivers
subject: 'This is test email', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>', // html body
});
console.log("Message sent: %s", info.messageId);
}();Regards
Allen Kim






