Advertisement
Guest User

Untitled

a guest
Jan 4th, 2019
172
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.     let tokens =  await oauth2Client.refreshAccessToken();
  15.     let accessToken = await tokens.credentials.access_token;
  16.     return accessToken;
  17.  
  18. };
  19. const smtpTransport = nodemailer.createTransport({
  20.     service: "gmail",
  21.     auth: {
  22.         type: "OAuth2",
  23.         user: "smartcityinab@gmail.com",
  24.         clientId: "566999579455-g6aqvufekk2fu80c91c99s0lrfn08ce0.apps.googleusercontent.com",
  25.         clientSecret: "TeDBOaL_UisYwH2eDCXzfmIo",
  26.         refreshToken: "1/T8ZdGK1NUpmV91cHe7h3EEnLCgC6VBoPv2KebDka0tQ",
  27.         accessToken: token()
  28.     }
  29. });
  30.  
  31.  
  32. const mailOptions = {
  33.     from: 'eliasxx@gmail.com', // sender address
  34.     to: 'elias.tardon.munoz@gmail.com', // list of receivers
  35.     subject: 'Subject of your email', // Subject line
  36.     html: '<p>Your html here</p>'// plain text body
  37.   };
  38.  
  39. module.exports ={
  40.     smtpTransport,
  41.     mailOptions
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement