: , Google , nodemailer. !
! , Google Admin Console . (, ) .
, Node.JS Quickstart API Google .
- console.developers.google.com, OAuth2.0 client_secret.json .
NPM google api.
npm install googleapis
npm install google-auth-library
quickstart.js
client_secret.json quickstart.js
7 quickstart.js - , . , . , . . API Gmail.
RUN node quickstart.js
URL- , . nodejs-gmail-quickstart.json, stdout.
, . , SCOPES, access_token .
: access_token 1 . refresh_token .
refresh_token!
auth 3LO Nodemailer. , . auth :
const mailbot = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
requireTLS: true,
auth: {
type : 'OAuth2',
user : config.client_email,
scope : "https://www.googleapis.com/auth/gmail.send",
clientId : config.client_id,
clientSecret: secret,
refreshToken: activeToken.refresh_token
}
});
: Gmail FROM , ( ). , { FROM: '"Display NAME" <user email>' }, , .
. nodemailer https://accounts.google.com/o/oauth2/token , access_token.
, nodemailer , , this.emit(). , , , , access_token .
[] , ! , 2LO , ID ID . , . . . Google Identity Platform (Nodemailer HTTP/REST)
[1] Google OAuth 2.0 https://accounts.google.com/o/oauth2/v2/auth. HTTPS. HTTP- .
[5] , - , .
TLS , refresh_token ( hassle, ), access_token, API Google.
, OAuth2.0 ( ), , , . !