node.js email doesn't get sent with gmail smtp

前端 未结 8 1936
广开言路
广开言路 2021-01-31 17:55

I\'m trying to send the email gmail smtp but I\'m getting the error:

My email and password is correct I\'m using the nodemailer for sending the mail;

            


        
8条回答
  •  醉梦人生
    2021-01-31 18:41

    Google don't allow you to send direct e-mail to other's. First of all you have to create a app password .For that thing please follow below steps to get it done

    1. Go to your manage account section.
    2. Then click on the security link in left side.
    3. In the signing in to the google click on app password and it will ask you to sign in again after sign in
    4. It will ask "select app", for mail purpose "select mail" and after that select device from which you want to send mail.
    5. After all these steps, it will generate password for that thing and insert that like this
        var smtpTransport = nodemailer.createTransport({
        service: "Gmail",
        auth: {
            user: "example@example.com",
            pass: "password"
        }
    

    That's it.

提交回复
热议问题