我正在尝试将 const data = 放入 ${body.email}。简单来说就是在前面打字发邮件
I am trying to put in const data = to the ${body.email}. To be simple, it's for sending e-mail while just typing in the front
const mail = require('@sendgrid/mail');
mail.setApiKey(process.env.SENDGRID_API_KEY);
export default async (req, res) => {
const body = JSON.parse(req.body);
const message = `
Name : ${body.name}\r\n
Prenom : ${body.prenom}\r\n
Adresse : ${body.adresse}\r\n
Téléphone : ${body.telephone}\r\n
email : ${body.email} \r\n
Type de bien : ${body.message}\r\n
Année de construction : ${body.annee}
`;
const data = {
to: ??????
from: 'souleymanportfolio@souleymanportfolio.com',
subject: 'Nouveau Lead!',
text: message,
html: message.replace(/\r\n/g, '<br>')
};
mail.send(data);
res.status(200).json({ status: 'Ok' });
请帮忙,我正在尝试将 const data = 放入 ${body.email}。简单来说就是在前面打字发邮件
谢谢。
此处为 Twilio SendGrid 开发人员布道师。
您可以将 data
对象上的 to
属性 设置为 body.email
,如下所示:
const data = {
to: body.email,
from: 'souleymanportfolio@souleymanportfolio.com',
subject: 'Nouveau Lead!',
text: message,
html: message.replace(/\r\n/g, '<br>')
};
const mail = require('@sendgrid/mail');
mail.setApiKey(process.env.SENDGRID_API_KEY);
export default async (req, res) => {
const body = JSON.parse(req.body);
const message = `
Name : ${body.name}\r\n
Prenom : ${body.prenom}\r\n
Adresse : ${body.adresse}\r\n
Téléphone : ${body.telephone}\r\n
email : ${body.email} \r\n
Type de bien : ${body.message}\r\n
Année de construction : ${body.annee}
`;
const data = {
to: ??????
from: 'souleymanportfolio@souleymanportfolio.com',
subject: 'Nouveau Lead!',
text: message,
html: message.replace(/\r\n/g, '<br>')
};
mail.send(data);
res.status(200).json({ status: 'Ok' });
请帮忙,我正在尝试将 const data = 放入 ${body.email}。简单来说就是在前面打字发邮件
谢谢。
此处为 Twilio SendGrid 开发人员布道师。
您可以将 data
对象上的 to
属性 设置为 body.email
,如下所示:
const data = {
to: body.email,
from: 'souleymanportfolio@souleymanportfolio.com',
subject: 'Nouveau Lead!',
text: message,
html: message.replace(/\r\n/g, '<br>')
};