Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch email from local app server. Nodejs

I have lite nodejs server. I am trying to implement password reset flow. I use nodemailer to send email with reset password link. I want to test if I send email properly. I don't want to use any remote smpt.

What I can use on my local environment to catch emails and check if they are good?

like image 995
Ivan Hreskiv Avatar asked Apr 26 '26 19:04

Ivan Hreskiv


2 Answers

I used mailcatcher. It is a super simple SMTP server which catches any message sent to it to display in a web interface.

I have following configuration:

let smtpConfig = {
  host: '127.0.0.1',
  port: 1025,
  secure: false, // upgrade later with STARTTLS
  auth: {
    user: 'user',
    pass: 'password'
  }
 };

Do not forget to add user and password in auth section. It can be even white space. But it can't be empty string in this case you'll get error.

const smtpTransport = nodemailer.createTransport(smtpConfig);

And now you can see all sent emails here http://127.0.0.1:1080

like image 72
Ivan Hreskiv Avatar answered Apr 28 '26 08:04

Ivan Hreskiv


Try this command:

python -m smtpd -n -c DebuggingServer localhost:1025
like image 45
Mykola Kharechko Avatar answered Apr 28 '26 07:04

Mykola Kharechko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!