Advertisement
Guest User

Untitled

a guest
Jan 28th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let nodemailer = require('nodemailer');
  2. let {google} = require('googleapis');
  3. const OAuth2 = google.auth.OAuth2;
  4. const oauth2Client = new OAuth2(
  5.     "566999579455-g6aqvufekk2fu80c91c99s0lrfn08ce0.apps.googleusercontent.com", // ClientID
  6.         "TeDBOaL_UisYwH2eDCXzfmIo", // Client Secret
  7.         "https://developers.google.com/oauthplayground" // Redirect URL
  8.  
  9. );
  10. oauth2Client.setCredentials({
  11.     refresh_token: "1/T8ZdGK1NUpmV91cHe7h3EEnLCgC6VBoPv2KebDka0tQ"
  12. });
  13. async function token(){
  14.     return await oauth2Client.getAccessToken();
  15.    
  16. };
  17. const smtpTransport = nodemailer.createTransport({
  18.     service: "gmail",
  19.     auth: {
  20.         type: "OAuth2",
  21.         user: "smartcityinab@gmail.com",
  22.         clientId: "566999579455-g6aqvufekk2fu80c91c99s0lrfn08ce0.apps.googleusercontent.com",
  23.         clientSecret: "TeDBOaL_UisYwH2eDCXzfmIo",
  24.         refreshToken: "1/T8ZdGK1NUpmV91cHe7h3EEnLCgC6VBoPv2KebDka0tQ",
  25.         headers: token()
  26.     }
  27. });
  28.  
  29.  
  30. const mailOptions = {
  31.     from: 'eliasxx@gmail.com', // sender address
  32.     to: 'elias.tardon.munoz@gmail.com', // list of receivers
  33.     subject: 'Subject of your email', // Subject line
  34.     html: '<p>Your html here</p>'// plain text body
  35.   };
  36.  
  37. module.exports ={
  38.     smtpTransport,
  39.     mailOptions
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement