Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sendemail import SendEmail # uses smtplib, socket
- from getheaders import GetHeaders # uses imaplib, email
- from printoutput import PrintOutput # uses email.utils, pytz, datetime, time
- send_email = SendEmail()
- send_email.config_connection(host='smtp.zoho.com', port=465, user='sending_to_forwarder@zoho.com', password='xxx')
- send_email.send(send_to='forwardtooutlook@var.ninja', message='email message, subject is timestamp') # connect and send email, then d/c
- if send_email.error:
- print(send_email.error)
- exit() # if senderrefused, socketerror, login error, authentication method error
- else:
- print('='*20 + '\n' + 'Message Sent' + '\n' + '='*20)
- get_headers = GetHeaders()
- get_headers.config_connection(user='forward_to@outlook.com', port=993, password='xxx', host='imap-mail.outlook.com') # config imap creds
- print_it = PrintOutput()
- print_it.printoutput(get_headers) # pass imap connection object, check server for new messages, parse headers of unseen messages, and print delay summary
- # PrintOutput does too much, will refactor
- #Output
- """
- ====================
- Message Sent
- ====================
- from [192.168.10.1] (50-46-215-239.evrt.wa.frontiernet.net [50.46.215.239]) by mx.zohomail.com
- with SMTPS id 1455691781661522.5883961538051; Tue, 16 Feb 2016 22:49:41 -0800 (PST)
- --------------------
- Delay at this hop: 0:00:00
- --------------------
- from sender153-mail.zoho.com (unknown [74.201.84.153])
- by c1mailgw11.amadis.com (Postfix) with ESMTP id 8E93B9BA1970C
- for <forwardtooutlook@var.ninja>; Tue, 16 Feb 2016 22:49:51 -0800 (PST)
- --------------------
- Delay at this hop: 0:00:10
- --------------------
- from 38.113.116.221 unverified ([38.113.116.221]) by mwpop05oc.mail2world.com with Mail2World SMTP Server;
- Tue, 16 Feb 2016 22:50:51 -0800
- --------------------
- Delay at this hop: 0:01:00
- --------------------
- from mail pickup service by mail2world.com with Microsoft SMTPSVC;
- Tue, 16 Feb 2016 22:50:54 -0800
- --------------------
- Delay at this hop: 0:00:03
- --------------------
- from mail2world.com ([209.67.128.125]) by SNT004-MC3F44.hotmail.com with Microsoft SMTPSVC(7.5.7601.23143);
- Tue, 16 Feb 2016 22:50:56 -0800
- --------------------
- Delay at this hop: 0:00:02
- --------------------
- from SNT004-MC3F44.hotmail.com (10.152.84.58) by
- BY2NAM03FT050.mail.protection.outlook.com (10.152.85.137) with Microsoft SMTP
- Server (TLS) id 15.1.415.6 via Frontend Transport; Wed, 17 Feb 2016 06:50:56
- +0000
- --------------------
- Delay at this hop: 0:00:00
- --------------------
- from BY2NAM03FT050.eop-NAM03.prod.protection.outlook.com
- (2a01:111:f400:7e4a::203) by BY2PR04CA0084.outlook.office365.com
- (2a01:111:e400:2c16::52) with Microsoft SMTP Server (TLS) id 15.1.409.15 via
- Frontend Transport; Wed, 17 Feb 2016 06:50:57 +0000
- --------------------
- Delay at this hop: 0:00:01
- --------------------
- from BY2PR04CA0084.namprd04.prod.outlook.com (10.255.247.52) by
- BY2PR0401MB0968.namprd04.prod.outlook.com (10.160.64.151) with Microsoft SMTP
- Server (TLS) id 15.1.409.15; Wed, 17 Feb 2016 06:50:57 +0000
- --------------------
- Delay at this hop: 0:00:00
- --------------------
- from BY2PR0401MB0968.namprd04.prod.outlook.com (10.160.64.151) by
- CY1PR0401MB0971.namprd04.prod.outlook.com (10.160.160.17) with Microsoft SMTP
- Server (TLS) id 15.1.403.16 via Mailbox Transport; Wed, 17 Feb 2016 06:50:57
- +0000
- --------------------
- Delay at this hop: 0:00:00
- --------------------
- ++++++++++++++++++++
- Total time to delivery: 0:01:16
- ++++++++++++++++++++
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement