What port should I use for sending emails from my Node.js app?

0
7
Asked By CuriousCoder42 On

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

Answered By MailGuru93 On

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.

Answered By EmailWizard On

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.

Answered By TechieTom On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.