2

Could be what I want to do is totally Impossible but I am a newbie so please understand, thanks.

Basically as you can see in my code, that replyTo and subject have a variable from where the information will be pulled from rather than plain text. I would like to know if there is any way I can do that to the from field. I want it to pull the information from the email name input like the subject does but haven't found a way. Cam anyone tell me if there is a way of achieving that?

Thank you guys.

 let mailOptions = {
 from: `sender <sender@example.com>`,
 to: 'me@gmail.com',
 replyTo: `<${req.body.Email}>`,
 subject: `${req.body.fname} ${req.body.lname} requested a quote`, 
 text: 'Hello world?', 
 html: output
};
BeckyP
  • 23
  • 4
  • Sorry I could not understand, so the exit field? It could give an even metaphorical example. – Chance Dec 12 '18 at 18:44

1 Answers1

0

You want to make sure you have ${variable} in your template strings ` `

 // req.body.from = 'sender <sender@example.com>';
 let mailOptions = {
     from: `${req.body.from}`,
     to: 'me@gmail.com',
     replyTo: `<${req.body.Email}>`,
     subject: `${req.body.fname} ${req.body.lname} requested a quote`, 
     text: 'Hello world?', 
     html: output
 };

Here is a link to MDN with another example:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Expression_interpolation

jemiloii
  • 24,594
  • 7
  • 54
  • 83