Brute
Brute

Reputation: 141

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

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!

Upvotes: 2

Views: 136

Answers (1)

Ayomide
Ayomide

Reputation: 109

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);
});

Upvotes: 1

Related Questions