Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const MailListener = require("mail-listener2");
- const mailService = function(){
- let mailListener = new MailListener({
- username: "prioooprotractor@gmail.com",
- password: "dvicaxgndraqhqdz",
- host: "imap.gmail.com",
- port: 993, // imap port
- tls: true,
- tlsOptions: { rejectUnauthorized: false },
- mailbox: "INBOX", // mailbox to monitor
- markSeen: true, // all fetched email willbe marked as seen and not fetched next time
- fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
- mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
- attachments: true, // download attachments as they are encountered to the project directory
- attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
- });
- this.start = () => {
- mailListener.start();
- };
- this.stop = () => {
- mailListener.stop();
- };
- this.getLastMail = () => {
- let deferred = protractor.promise.defer();
- mailListener.on("mail", function(mail){
- deferred.fulfill(mail);
- });
- return deferred.promise;
- };
- };
- module.exports = new mailService();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement