DEV Community

How to send Email with node js for free

fawazsullia on May 31, 2021

If you are building a project that involves customer interactions, then probably at some point you would have to send them an email as well. For e...
Collapse
 
sebbdk profile image
Sebastian Vargr

I think this article should come with a disclaimer. :)

The reason people might wanna use MailChimp or other services is that their IP's are not blacklisted, known to email-providers, properly encrypted etc.

Without all of that, there's a really good chance the email's will end up blackholed or in the spam folder.

Not bashing on the article here, but just so everyone understands that this should not be used in a production environment with customers if you want them to get your emails.

For personal projects & prototypes then this approach is fine. :)

Collapse
 
fawazsullia profile image
fawazsullia

Thanks Sebastian. Is there a way to avoid my servers being black listed?

Collapse
 
sebbdk profile image
Sebastian Vargr

It's not something I have delved into personally. :)

I would probably look the other way around, and look to get whitelisted with the various larger email providers somehow.

It's also possible they have a common third-party one can get whitelisted with such as spamhaus.org/

There's bound to be some articles on how to not get spam'canned out there that would be worth looking up. :)

Thread Thread
 
fawazsullia profile image
fawazsullia

Yup. Makes sense not reinventing the wheel!

Collapse
 
zxcodes profile image
Mohammed Farmaan.

Can this be done with vanilla JS? Like in React?

Collapse
 
redrogue12 profile image
Edgar X. González Cortés

Hey! To solve your problem you can create a nodejs server and create an endpoint that sends the email like in this post. In your React app you can use axios to hit the endpoint and thus sending the email. Just send the message in the parameters so it can be dynamic.

Collapse
 
zxcodes profile image
Mohammed Farmaan.

Yeah got it. Thanks for answering!😄

Collapse
 
fawazsullia profile image
fawazsullia

I guess no. you need a server to send email via nodemailer

Collapse
 
ezzabuzaid profile image
ezzabuzaid

You can't.

What you can do is to use cloud functions such as firebase functions, aws lambda or azure functions.

Collapse
 
aadityasiva profile image
Aadityasiva

No it cant be react is a frontend library not a backend library but you can use expressjs to setup a API and acess it from react

Collapse
 
barelyhuman profile image
Reaper

You could use mailer.reaper.im

Collapse
 
emadbaqeri profile image
Emad Baqeri

I'm trying to implement a welcome mailer function but I'm stock for 2 hours right now.