Home > Back-end >  How to send an Email with a locally running SMTP/IMAP Server using Reactjs?
How to send an Email with a locally running SMTP/IMAP Server using Reactjs?

Time:02-08

I've have been searching online for sending emails using reactjs and they all seem to be working by installling email.js and registering it through their domain.

However, I have a locally running SMTP server on my server that can send and receive emails though my domain.

I was wondering how I can use this service via ReactJs and JavaScript?

I also on the same server have a Nextlcloud Instance running and it can send out emails successfully without any outside configuration done for password resets and other things.

Any help or links would be much appreciated to help solve this. If I need to clarify anything more, please let me know. I was thinking of having some text boxes that a person can type into and they click submit and it will send out a specific email from my domain.

CodePudding user response:

The only network protocols you can use client-side JS to communicate with are HTTP and Websockets.

You cannot connect directly to an SMTP server from a web browser.

(If you could, and you handed over the credentials to send an email from your server using raw SMTP then you’d effectively turn your mail server into a spam relay, so this wouldn’t be desirable anyway).

You need a webservice that accepts an HTTP request from the browser and sends the email.

smtp.js is a third-party service which does this.

You can write you own so that you don’t need to give your mail server credentials to a third-party.

  •  Tags:  
  • Related