【发布时间】:2020-11-23 16:20:21
【问题描述】:
我在尝试使用 nodemailer 发送邮件时收到错误代码 500。我是 Firebase 功能和快递。 看看我的代码,告诉我我做错了什么。
const gmailEmail = functions.config().gmail.login;
const gmailPassword = functions.config().gmail.pass;
admin.initializeApp();
app.post('/visitor/contact', (req, res, next) => {
return cors()(req, res, () => {
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
//transporter is a way to send your emails
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: gmailEmail,
pass: gmailPassword
}
});
// setup email data with unicode symbols
//this is how your email are going to look like
const mailOptions = {
from: gmailEmail,
to: req.body.email,
subject: 'Full stack developer',
html: `<h1 style="color:blue;">Welcome ${req.body.firstName}</h1>
<p style="font-size:25px;">Thank you very much for contacting me. i hope you are having a great time where ever you may be.</p>
<p style="font-size:25px;">I am a full stack developer by training and i am available at the moment for a MEAN stack job That will challenge me to be better.</p>
<p style="font-size:23px;">Thanks ${req.body.firstName}</p>`
};
transporter.sendMail(mailOptions);
next();
});
});
【问题讨论】:
标签: firebase express google-cloud-functions nodemailer