Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

自分用メモ

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アカウントで、以下を設定。
「安全性の低いアプリの許可:」を有効にする

https://myaccount.google.com/lesssecureapps

hshimo
ブロックチェーン専門企業、コンセンサス・ベイス代表、志茂 博の技術メモ。 興味ある方は、日本ブロックチェーンユーザ会へ。http://crypto-tech.jp/
http://www.consensus-base.com/
consensus-base
ブロックチェーン技術の専門企業。大企業様を中心に国内有数の実証実験・開発の実績があり、様々な実装の経験・ノウハウがある。
http://www.consensus-base.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした