Как перейти к следующей строке в nodeJS - PullRequest
0 голосов
/ 04 января 2019

Сегодня я только начал с триггера аутентификации NodeJ firebase, чтобы отправить приветственное письмо при первой регистрации пользователя. Вот файл 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}

1 Ответ

0 голосов
/ 04 января 2019

не могли бы вы попробовать это и поделиться выводом ...

 mailOptions.text = `Hey ${displayName || ''}! Welcome to ${APP_NAME}. \n We hope you will enjoy our service.`;

вам нужно будет вставить html-опцию , если вы хотите добавить ссылку на изображение ... предыдущий код (выше) отправлял только текстовые сообщения

mailOptions.html = `
Hey ${displayName || ''}! Welcome to ${APP_NAME}.  
<br />
<img src="cid:logo">
<br/>
We hope you will enjoy our service. <br/> `;

и

mailOptions.attachments = [{
            filename: 'angular.png',
            path: 'https://www.akberiqbal.com/logos/angular.png',
            cid: 'logo'
}]
...