Reputation: 1721
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..
Upvotes: 3
Views: 3620
Reputation: 79
If anyone is still trying to receive emails with Node JS i would recommend node-mailin. It is almost the same as mailin (which is not mainted anymore). Emails sent to your server get parsed as JSON and you can do anything with them. You can also reject emails based on the senders email address or IP or if it is send to an email adress you don't want to be used.
Upvotes: 0
Reputation: 3566
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.
Upvotes: 1