Hey everyone! I'm developing an email solution using Node.js and I need some advice on which port to use for relaying emails. In my processQueue() function, I'm working with MongoDB documents that represent emails, and I use Nodemailer to send these emails to the MX host. My main question is whether I should try sending emails via tcp/25 with STARTTLS (starting in cleartext) or should I go for tcp/587 with TLS from the start, and only fall back to tcp/25 with STARTTLS if the first option doesn't work. It's been over 20 years since I was last an email admin, so any insights would be greatly appreciated!
3 Answers
I recommend starting with fully encrypted connections. It's crucial to avoid sending unencrypted emails over port 25 as much as possible. Your code should ideally require STARTTLS before any email transmission occurs.
Port 25 is usually for server-to-server relaying, best with STARTTLS. Port 587 is preferred for client-to-server submissions using STARTTLS, which is safer and more modern.
You should definitely look into email delivery best practices. When you're emailing directly from your app, it's a good idea to code for all three options—start with the most secure (tcp/587 with TLS), then tcp/25 with STARTTLS if that doesn’t work. Alternatively, consider using a Mail Transfer Agent (MTA) to handle the email delivery for you.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically