Advertisement
Guest User

Untitled

a guest
Oct 7th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. const MailListener  = require("mail-listener2");
  4.  
  5. const mailService = function(){
  6.     let mailListener = new MailListener({
  7.         username: "prioooprotractor@gmail.com",
  8.         password: "dvicaxgndraqhqdz",
  9.         host: "imap.gmail.com",
  10.         port: 993, // imap port
  11.         tls: true,
  12.         tlsOptions: { rejectUnauthorized: false },
  13.         mailbox: "INBOX", // mailbox to monitor
  14.         markSeen: true, // all fetched email willbe marked as seen and not fetched next time
  15.         fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
  16.         mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
  17.         attachments: true, // download attachments as they are encountered to the project directory
  18.         attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
  19.     });
  20.  
  21.     this.start = () => {
  22.         mailListener.start();
  23.     };
  24.  
  25.     this.stop = () => {
  26.         mailListener.stop();
  27.     };
  28.  
  29.     this.getLastMail = () => {
  30.         let deferred = protractor.promise.defer();
  31.    
  32.         mailListener.on("mail", function(mail){
  33.             deferred.fulfill(mail);
  34.         });
  35.        
  36.         return deferred.promise;
  37.     };
  38. };
  39.  
  40. module.exports = new mailService();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement