27
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nodemailerでGmailから送信するための方法

Last updated at Posted at 2017-07-25

自分用メモ

nodemailerでの設定

    var smtpConfig = {
        host: 'smtp.gmail.com',
        port: 465,
        secure: true, // SSL
        auth: {
            user: 'なんとか@gmail.com',
            pass: 'パスワード'
        }
    };
    this.transporter = mailer.createTransport(smtpConfig)

Gmailの設定

  1. 二段階認証がONの場合: アプリパスワードみたいなもので認証
  2. 二段階認証が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アカウントで、以下を設定。
「安全性の低いアプリの許可:」を有効にする

27
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?