Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending and receiving emails using node.js server

I have to implement email server like webmail in nodeJS and angular 6.

About my scenario, user needs to provide their email and email password.Then I have to identify their smtp server address and authenticate. After that user should able to send & receive email which connected to provided email.

I have researched what are the options I have and most of articles says node-mailer is the best for sending emails but there is no feature for receive email and node-imap ,apart from those my best option so far is mailin library.

I have try to do it in mailin but I'm recently started node development with my new job and can't understand most of implementation in mailin library.

If someone can help me with mailin code samples or tell me if there is other options.it'll be very helpful..

like image 349
Isanka Thalagala Avatar asked Mar 14 '26 10:03

Isanka Thalagala


1 Answers

Just follow the examples from the doc:

Create folder for your project and navigate to it.

Install Mailin: sudo npm install mailin

Create index.js file with this content source from docs. mailin.on('authorizeUser' is not needed, you can leave it.

Start the app: node index.js

You need to allow the port that is used 25. In the console in your server type ufw allow 25.

You need to add DNS record to point to your server in your hosting panel.

Now you can test the server with Telnet in your PC. Try to connect to it with:

telnet domain-for-the-server.com 25

You can send an email to [email protected]

The event that you need index.js is mailin.on('message'.... You can type console.log(data);, restart the app and when you send mail, you will see the data in the console.

like image 140
gdfgdfg Avatar answered Mar 16 '26 22:03

gdfgdfg



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!