自分用メモ
nodemailerでの設定
var smtpConfig = {
host: 'smtp.gmail.com',
port: 465,
secure: true, // SSL
auth: {
user: 'なんとか@gmail.com',
pass: 'パスワード'
}
};
this.transporter = mailer.createTransport(smtpConfig)
Gmailの設定
- 二段階認証がONの場合: アプリパスワードみたいなもので認証
- 二段階認証がOFFの場合: 安全性の低いアプリの許可を有効にする?
以下のようなエラーが出る場合
response: '534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbun\n534-5.7.14 Js5HEiTBKrTKTK_QrftVcMYM7AL6D5RBOq79Zfhx7K7hvX_oLs3DIFeC6V7DDvoMWK2tgV\n534-5.7.14 6y7yhKzKLI1szpaK-KH7eZiYfgQJ8AHYF-IdkqhzCZxMUD_SKf-yvY3lzbER8pxAZQ_SKb\n534-5.7.14 OVeT5VVCmErNorFMolwRaBy-eIW1GUkGLnJ5uVCV6WAsPKT1GpsRJzWvfOTfOplIxQSsvG\n534-5.7.14 wCHdBa8IFUCmxFBu5qusCY5EHGRLk> Please log in via your web browser and\n534-5.7.14 then try again.\n534-5.7.14 Learn more at\n534 5.7.14 https://support.google.com/mail/answer/78754 64sm24768128pff.168 - gsmtp',
responseCode: 534,
command: 'AUTH PLAIN' }
(node:14969) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbun
534-5.7.14 Js5HEiTBKrTKTK_QrftVcMYM7AL6D5RBOq79Zfhx7K7hvX_oLs3DIFeC6V7DDvoMWK2tgV
534-5.7.14 6y7yhKzKLI1szpaK-KH7eZiYfgQJ8AHYF-IdkqhzCZxMUD_SKf-yvY3lzbER8pxAZQ_SKb
534-5.7.14 OVeT5VVCmErNorFMolwRaBy-eIW1GUkGLnJ5uVCV6WAsPKT1GpsRJzWvfOTfOplIxQSsvG
534-5.7.14 wCHdBa8IFUCmxFBu5qusCY5EHGRLk> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 64sm24768128pff.168 - gsmtp
自分のGmailアカウントで、以下を設定。
「安全性の低いアプリの許可:」を有効にする