【发布时间】:2019-05-30 23:21:44
【问题描述】:
今天我刚开始使用 firebase NodeJs 身份验证触发器,用于在用户首次注册时发送欢迎电子邮件。这是官方文档中的 index.js 文件(修改)
const APP_NAME = 'Incredible India Tourism';
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
const email = user.email; // The email of the user.
const displayName = user.displayName; // The display name of the user.
return sendWelcomeEmail(email, displayName);
});
exports.sendByeEmail = functions.auth.user().onDelete((user) => {
// [END onDeleteTrigger]
const email = user.email;
const displayName = user.displayName;
return sendGoodbyeEmail(email, displayName);
});
// [END sendByeEmail]
// Sends a welcome email to the given user.
function sendWelcomeEmail(email, displayName) {
const mailOptions = {
from: `${APP_NAME} <noreply@firebase.com>`,
to: email,
};
// The user subscribed to the newsletter.
mailOptions.subject = `Welcome to ${APP_NAME}!`;
mailOptions.text = `Hey ${displayName || ''}! Welcome to ${APP_NAME}. We hope you will enjoy our service.`;
return mailTransport.sendMail(mailOptions).then(() => {
return console.log('New welcome email sent to:', email);
});
}
// Sends a goodbye email to the given user.
function sendGoodbyeEmail(email, displayName) {
const mailOptions = {
from: `${APP_NAME} <noreply@firebase.com>`,
to: email,
};
// The user unsubscribed to the newsletter.
mailOptions.subject = `Bye!`;
mailOptions.text = `Hey ${displayName || ''}!, We confirm that we have deleted your ${APP_NAME} account.`;
return mailTransport.sendMail(mailOptions).then(() => {
return console.log('Account deletion confirmation email sent to:', email);
});
}
但是我如何才能移到这一行的下一行
mailOptions.text = `Hey ${displayName || ''}! Welcome to ${APP_NAME}. We hope you will enjoy our service.`;
我想移到下一行
Welcome to ${APP_NAME}
【问题讨论】:
-
New Line in Node.js的可能重复
-
是的,我试过了,但无法在这里实现。我是 nodejs 的新手
-
你写\n或\r\n时发生了什么...结果是什么?
-
什么都没有发生,但实际上开始出错,您引用的链接完全不同。就我而言,所有都是字符串,所以我不知道应该在哪里使用 + "\r\n"
标签: node.js firebase npm google-cloud-functions nodemailer