I'm creating a nodemailer on my app, and I want to send email dynamically from input field that user will fill up. E.g. If the user writes on form input email value: 'test@test.com' I want to send this email from 'test@test.com' so later I can answer to this person and have all history of emails.
Edit
Step 1:
Fill up form on website with your personal data. E.g. I want to send email to company (name: josh, surname: murp, email: josh22@domain.com)
Step 2:
Send this json object to '/contactus/'
with fetch and log this in console with req.body
I'm getting this obj: { name: 'josh', surname: 'murp', email: 'josh22@domain.com' }
Step 3:
I want to setup Nodemailer in that way:
let mailOptions = {
from: `${req.body.firstName} ${req.body.surname} <${req.body.email}>`, // sender address
to: "mymail@gmail.com", // list of receivers
subject: "hi", // Subject line
text: "Hello world", // plain text body
html: "<b>NodeJS Email Tutorial</b>" // html body
};
That means. I want to get email FROM req.body.email, in real life I want to get EMAIL from josh22@domain.com
but Nodemailer use TRANSPORTER to send email. It means I'm getting email from email configured in transporter but I want to get EMAIL from JOSH
This result brings me an issue.
When I got email from my account (transporter) I'm not able to answer this mail I need to find who is writing to me and in CONVERSATION HISTORY I don't have FIRST email of this conversation what was send via my website.
One big question here:
HOW TO SET DYNAMIC TRANSPORTER? or how to implement this in Node/express
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: keys.username, // generated ethereal user
pass: keys.password // generated ethereal password
}
});
I'm looking all day to find this answer in web, but no result.
from Nodemailer - dynamic transporter
No comments:
Post a Comment