Initial import
This commit is contained in:
49
one-api/scripts/t01-email.py
Normal file
49
one-api/scripts/t01-email.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import smtplib
|
||||
import urllib
|
||||
import urllib2
|
||||
from email.MIMEMultipart import MIMEMultipart
|
||||
from email.MIMEBase import MIMEBase
|
||||
from email.MIMEText import MIMEText
|
||||
from email import Encoders
|
||||
from PyPDF2 import PdfFileWriter, PdfFileReader
|
||||
import StringIO
|
||||
import json
|
||||
import pdb
|
||||
import time
|
||||
|
||||
|
||||
|
||||
def sendEmailText(rec,subject,i_msg):
|
||||
server = g_server
|
||||
to_addrs = [rec]
|
||||
xfrom = g_from
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = g_from
|
||||
msg['To'] = rec
|
||||
msg['Subject'] = subject
|
||||
msg.attach(MIMEText(i_msg))
|
||||
|
||||
rst = True
|
||||
try :
|
||||
s = smtplib.SMTP(server,587)
|
||||
s.set_debuglevel(7)
|
||||
s.starttls()
|
||||
s.login(g_login,g_password)
|
||||
s.sendmail(xfrom, to_addrs, msg.as_string())
|
||||
s.close()
|
||||
except:
|
||||
rst =False
|
||||
return rst
|
||||
|
||||
|
||||
email="padmanto@gmail.com"
|
||||
subject="Test subject email"
|
||||
message="body message"
|
||||
g_server = "smtp.gmail.com"
|
||||
g_login = "smartlabresult@gmail.com"
|
||||
g_password = "sms102938"
|
||||
g_from = "SmartLab Result<smartlabresult@gmail.com>"
|
||||
sendEmail(email,subject,message,url_report,fname,passwd)
|
||||
|
||||
Reference in New Issue
Block a user