Home > OS >  How to send an email to an address from user input feild in React.js/Express.js?
How to send an email to an address from user input feild in React.js/Express.js?

Time:09-17

I am making a basic email app where a user can send an email to whomever they like. I want to be able to send an email to user-specified email address. I can't use nodemailer because it requires password and user.id and I dont want to ask for a password from the user.

I have been searching Google for two days now and all the I can find is how to send an email to yourself and not to user-generated input.

It would be great if anyone could point me in the right direction.

Thanks!

CodePudding user response:

Nodemailer has a sendmail transport that allows you to send mail without any authentication.

let transporter = nodemailer.createTransport({
sendmail: true,
newline: 'unix',
    path: '/usr/sbin/sendmail'
});
   transporter.sendMail({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Message',
    text: 'I hope this message gets delivered!'
}, (err, info) => {
    console.log(info.envelope);
    console.log(info.messageId);
});
  • Related