本文整理汇总了Python中smtplib.SMTP_SSL类的典型用法代码示例。如果您正苦于以下问题:Python SMTP_SSL类的具体用法?Python SMTP_SSL怎么用?Python SMTP_SSL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMTP_SSL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sendmail
def sendmail(to_addrs, subject, text):
server = config.get('smtp_server')
use_tls = asbool(config.get('smtp_use_tls'))
username = config.get('smtp_username')
password = config.get('smtp_password')
from_addr = config.get('admin_email_from')
log.debug('Sending mail via %s' % server)
if use_tls:
s = SMTP_SSL()
else:
s = SMTP()
s.connect(server)
if username:
s.login(username, password)
msg = MIMEText(text, _charset='utf-8')
msg['From'] = from_addr
msg['Reply-To'] = from_addr
if isinstance(to_addrs, basestring):
msg['To'] = to_addrs
else:
msg['To'] = ', '.join(to_addrs)
msg['Subject'] = subject
s.sendmail(from_addr, to_addrs, msg.as_string())
s.quit()
开发者ID:samsemilia7,项目名称:SAUCE,代码行数:27,代码来源:mail.py
示例2: _sendMail
def _sendMail(self, message, request):
if message['subject']=='QUESTION':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+'QUESTION: '+message['question']+'\r\n'
elif message['subject']=='ORDER':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+ \
'ENTIRE LANGUAGE: '+message['entire_language']+'\r\n'+'CAPTION LANGUAGE: '+message['caption_language']+ \
'\r\n'+'VIDEO DURATION: '+message['duration']+'\r\n'+'TIME LIMIT: '+message['time_limit']+ \
'\r\n'+'VOICE OVER: '+message['voice_over']+'\r\n'+'DISCOUNT: '+message['discount']+'\r\n'+ \
'VIDEO LINK:'+message['videolink']+'\r\n'+'SPECIAL: '+message['special']
elif message['subject']=='CUSTOM ORDER':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+'COMPANY: '+ \
message['company']+'\r\n'+'REQUIREMENTS: '+message['requirements']
elif message['subject']=='FREE MINUTE':
txt='\r\n'+'EMAIL: '+message['email']+'\r\n'
msg=MIMEText(txt)
msg['Subject']=message['subject']
msg['From']=message['email']
msg['To']=self.addr
smtp = SMTP_SSL(self.hst)
smtp.login(self.addr,self.psswd)
smtp.sendmail(self.addr,self.addr,msg.as_string())
request.write('Your mail sent.')
request.finish()
开发者ID:girinvader,项目名称:SubtitleMe,代码行数:25,代码来源:twstd.py
示例3: __init__
def __init__(self, **kw):
args = {}
for k in ('host', 'port', 'local_hostname', 'keyfile', 'certfile', 'timeout'):
if k in kw:
args[k] = kw[k]
SMTP_SSL.__init__(self, **args)
SMTPClientWithResponse.__init__(self, **kw)
开发者ID:jesserobertson,项目名称:python-emails,代码行数:7,代码来源:client.py
示例4: render_POST
def render_POST(self, request):
message = ast.literal_eval(request.content.read())
if message['subject']=='QUESTION':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+'QUESTION: '+message['question']+'\r\n'
elif message['subject']=='ORDER':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+ \
'ENTIRE LANGUAGE: '+message['entire_language']+'\r\n'+'CAPTION LANGUAGE: '+message['caption_language']+ \
'\r\n'+'VIDEO DURATION: '+message['duration']+'\r\n'+'TIME LIMIT: '+message['time_limit']+ \
'\r\n'+'VOICE OVER: '+message['voice_over']+'\r\n'+'DISCOUNT: '+message['discount']+'\r\n'+ \
'VIDEO LINK:'+message['videolink']+'\r\n'+'SPECIAL: '+message['special']
elif message['subject']=='CUSTOM ORDER':
txt='\r\n'+'NAME: '+message['name']+'\r\n'+'\r\n'+'EMAIL: '+message['email']+'\r\n'+'\r\n'+'COMPANY: '+ \
message['company']+'\r\n'+'REQUIREMENTS: '+message['requirements']
elif message['subject']=='FREE MINUTE':
txt='\r\n'+'EMAIL: '+message['email']+'\r\n'
msg=MIMEText(txt)
msg['Subject']=message['subject']
msg['From']=message['email']
msg['To']=self.addr
request.setHeader("Access-Control-Allow-Origin", "*")
smtp = SMTP_SSL(self.hst)
smtp.login(self.addr,self.psswd)
smtp.sendmail(self.addr,self.addr,msg.as_string())
return 'Your mail sent.'
开发者ID:girinvader,项目名称:SubtitleMe,代码行数:26,代码来源:yandex_smtp.py
示例5: send
def send(message):
global datas
global numbers
s = SMTP_SSL('smtp.gmail.com', 465, timeout=10)
s.login(datas[0],datas[1])
for n in numbers:
s.sendmail(datas[0], numbers[n], str(message))
s.quit
开发者ID:sonicfreak02,项目名称:ThaneOfWhiterun,代码行数:8,代码来源:ToW.py
示例6: send_mail
def send_mail(message):
try:
smtpObj = SMTP_SSL(mail_host,465)
smtpObj.login(mail_user, mail_pass)
smtpObj.sendmail(sender, receivers, message.as_string())
print "邮件发送成功"
except smtplib.SMTPException:
print "无法发送邮件"
开发者ID:BrutyLi,项目名称:python-,代码行数:8,代码来源:sendmail.py
示例7: _open
def _open(self):
if self.conn:
return
conn = SMTP_SSL(self.config_d['smtp_host'],
self.config_d['smtp_port'])
conn.ehlo()
conn.login(self.config_d['smtp_user'],
self.config_d['smtp_password'])
self.conn = conn
开发者ID:headmin,项目名称:zentral,代码行数:9,代码来源:email.py
示例8: render_POST
def render_POST(self, request):
print request.content.read()
addr='[email protected]'
msg=MIMEMultipart()
msg['From']=msg['To']=addr
request.setHeader("Access-Control-Allow-Origin", "*")
smtp = SMTP_SSL('smtp.yandex.ru:465')
smtp.login('[email protected]','48919o6')
smtp.sendmail(addr,addr,msg.as_string())
return 'Your mail sent.'
开发者ID:BlackCab,项目名称:SubtitleMe,代码行数:10,代码来源:yandex_smtp.py
示例9: sendMessage
def sendMessage(self, sender, password, recipient, subject, body, attachmentFilenames=[]):
if type(attachmentFilenames) != list:
attachmentFilenames = [attachmentFilenames]
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipient
msg['Date'] = formatdate(localtime=True)
msg.attach(MIMEText(body, 'html'))
for filename in attachmentFilenames:
part = MIMEBase('application', "octet-stream")
part.set_payload(open(filename, "rb").read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % basename(filename))
msg.attach(part)
self.out.put("connecting...")
mailServer = SMTP_SSL(self.smtpHost, 465)
mailServer.ehlo()
self.out.put("logging in...")
mailServer.login(sender, password)
self.out.put("sending...")
mailServer.sendmail(sender, recipient, msg.as_string()) # raise if email is not sent
mailServer.quit()
self.out.put("done.")
开发者ID:CronWorks,项目名称:py-base,代码行数:28,代码来源:Emailer.py
示例10: landing_customer_contacts
def landing_customer_contacts(customer_email, customer_phone, customer_session):
"""
Функция отправки контактных данных полученных с лендинга.
:return:
"""
msg = email.MIMEMultipart.MIMEMultipart()
from_addr = "[email protected]"
to_addr = "[email protected], [email protected]"
msg['From'] = from_addr
msg['To'] = to_addr
text = "\tE-mail: %s \n\tТелефон: %s \n" % (customer_email, customer_phone)
text += "\tДата и время: %s \n" % datetime.datetime.now()
text += "Параметры сессии: \n "
for a,b in customer_session.items():
text += "\t%s : %s \n" % (a, b)
msg['Subject'] = Header("Контакты с лендинга Conversation parser", "utf8")
body = "Оставлены контакты. \n" + text
msg.preamble = "This is a multi-part message in MIME format."
msg.epilogue = "End of message"
msg.attach(email.MIMEText.MIMEText(body, "plain", "UTF-8"))
smtp = SMTP_SSL()
smtp.connect(smtp_server)
smtp.login(from_addr, "Cthutq123")
text = msg.as_string()
smtp.sendmail(from_addr, to_addr.split(","), text)
smtp.quit()
开发者ID:jitterxx,项目名称:comparser,代码行数:32,代码来源:objects.py
示例11: sendmail
def sendmail(to_mails, message):
# Update settings
apply_db_settings(flask_app.flask_app)
mail = 'From: {}\nTo: {}\nSubject: {}\n\n{}'.format(
flask_app.flask_app.config.get('EMAIL_EMAIL_FROM'),
to_mails,
flask_app.flask_app.config.get('EMAIL_SUBJECT'),
message
).encode(encoding='utf-8')
server_str = '{}:{}'.format(flask_app.flask_app.config.get('EMAIL_HOST', '127.0.0.1'),
flask_app.flask_app.config.get('EMAIL_PORT', 25))
server = SMTP_SSL(server_str) if flask_app.flask_app.config.get('EMAIL_ENCRYPTION', 0) == 2 \
else SMTP(server_str)
if flask_app.flask_app.config.get('EMAIL_ENCRYPTION', 0) == 1:
server.starttls()
if flask_app.flask_app.config.get('EMAIL_AUTH', 0):
server.login(flask_app.flask_app.config.get('EMAIL_LOGIN'),
flask_app.flask_app.config.get('EMAIL_PASSWORD'))
server.sendmail(flask_app.flask_app.config.get('EMAIL_EMAIL_FROM'),
to_mails,
mail)
server.quit()
开发者ID:Emercoin,项目名称:emcweb,代码行数:26,代码来源:tasks.py
示例12: sendMail
def sendMail(emailTo, subject, msgText, fileAddr):
filepath = fileAddr
basename = os.path.basename(filepath)
address = "[email protected]"
# Compose attachment
part = MIMEBase('application', "octet-stream")
part.set_payload(open(filepath,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % basename)
part3 = MIMEBase('application', "octet-stream")
part3.set_payload(open(os.getcwd() + '/plan_rabot_po_saitu_na_god.xlsx',"rb").read() )
Encoders.encode_base64(part3)
part3.add_header('Content-Disposition', 'attachment; filename="plan_rabot_po_saitu_na_god.xlsx"')
part2 = MIMEText(msgText, 'plain')
# Compose message
msg = MIMEMultipart()
msg['From'] = 'Михаил Юрьевич Бубновский <[email protected]>'
msg['To'] = emailTo
msg['Subject'] = subject
msg.attach(part2)
msg.attach(part)
msg.attach(part3)
# Send mail
smtp = SMTP_SSL()
smtp.connect('smtp.yandex.ru')
smtp.login(address, 'biksileev')
smtp.sendmail(address, emailTo, msg.as_string())
smtp.quit()
开发者ID:jz36,项目名称:megaindex-audit,代码行数:32,代码来源:tryUI.py
示例13: sent
def sent(filepath):
from smtplib import SMTP_SSL
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email import Encoders
import os
#filepath = "/path/to/file"
basename = os.path.basename(filepath)
address = 'adr'
address_to = "[email protected]"
# Compose attachment
part = MIMEBase('application', "octet-stream")
part.set_payload(open(filepath,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % basename)
# Compose message
msg = MIMEMultipart()
msg['From'] = address
msg['To'] = address_to
msg.attach(part)
# Send mail
smtp = SMTP_SSL()
smtp.connect('smtp.yandex.ru')
smtp.login(address, 'password')
smtp.sendmail(address, address_to, msg.as_string())
smtp.quit()
开发者ID:iiilia,项目名称:medinf,代码行数:30,代码来源:save_file.py
示例14: _use_smtp
def _use_smtp(self, subject, body, path):
# if self.smtp_server is not provided than don't try to send email via smtp service
logging.debug('SMTP Mail delivery: Started')
# change to smtp based mail delivery
# depending on encrypted mail delivery, we need to import the right lib
if self.smtp_encryption:
# lib with ssl encryption
logging.debug('SMTP Mail delivery: Import SSL SMTP Lib')
from smtplib import SMTP_SSL as SMTP
else:
# lib without encryption (SMTP-port 21)
logging.debug('SMTP Mail delivery: Import standard SMTP Lib (no SSL encryption)')
from smtplib import SMTP
conn = False
try:
outer = MIMEMultipart()
outer['Subject'] = subject # put subject to mail
outer['From'] = 'Your PicoChess computer <{}>'.format(self.smtp_from)
outer['To'] = self.email
outer.attach(MIMEText(body, 'plain')) # pack the pgn to Email body
ctype, encoding = mimetypes.guess_type(path)
if ctype is None or encoding is not None:
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
if maintype == 'text':
with open(path) as fpath:
msg = MIMEText(fpath.read(), _subtype=subtype)
elif maintype == 'image':
with open(path, 'rb') as fpath:
msg = MIMEImage(fpath.read(), _subtype=subtype)
elif maintype == 'audio':
with open(path, 'rb') as fpath:
msg = MIMEAudio(fpath.read(), _subtype=subtype)
else:
with open(path, 'rb') as fpath:
msg = MIMEBase(maintype, subtype)
msg.set_payload(fpath.read())
encoders.encode_base64(msg)
msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(path))
outer.attach(msg)
logging.debug('SMTP Mail delivery: trying to connect to ' + self.smtp_server)
conn = SMTP(self.smtp_server) # contact smtp server
conn.set_debuglevel(False) # no debug info from smtp lib
if self.smtp_user is not None and self.smtp_pass is not None:
logging.debug('SMTP Mail delivery: trying to log to SMTP Server')
conn.login(self.smtp_user, self.smtp_pass) # login at smtp server
logging.debug('SMTP Mail delivery: trying to send email')
conn.sendmail(self.smtp_from, self.email, outer.as_string())
# @todo should check the result from sendmail
logging.debug('SMTP Mail delivery: successfuly delivered message to SMTP server')
except Exception as smtp_exc:
logging.error('SMTP Mail delivery: Failed')
logging.error('SMTP Mail delivery: ' + str(smtp_exc))
finally:
if conn:
conn.close()
logging.debug('SMTP Mail delivery: Ended')
开发者ID:antmp27,项目名称:Picochess_NonDGT_LCD_0.9j,代码行数:60,代码来源:pgn.py
示例15: send
def send(self, *args, **kwargs):
picture = kwargs.get('pic')
msg = MIMEMultipart()
msg['Charset'] = "UTF-8"
msg['Date'] = formatdate(localtime=True)
msg['From'] = self.login + '@' + '.'.join(self.smtp.split('.')[1:])
msg['Subject'] = "Détection d'un mouvement suspect"
msg['To'] = self.send_to
msg.attach(MIMEText('', 'html'))
part = MIMEBase('application', 'octet-stream')
fp = open(picture, 'rb')
part.set_payload(fp.read())
encode_base64(part)
part.add_header('Content-Disposition', 'attachment', filename=picture)
msg.attach(part)
try:
server = SMTP_SSL(self.smtp, self.port)
server.set_debuglevel(False)
server.ehlo
server.login(self.login, self.password)
try:
server.sendmail(self.From, self.send_to, msg.as_string())
finally:
server.quit()
except Exception as e:
logging.critical("Unable to send an email\n{0}".format(str(e)))
sys.exit(2)
开发者ID:Chipsterjulien,项目名称:mailmotiond,代码行数:33,代码来源:main.py
示例16: send_mail
def send_mail(receivers, subject, content, attachment=None, filename=None):
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = config.FROM_EMAIL
msg['To'] = receivers
if config.DEV_ENV:
msg['To'] = config.TEST_TO_EMAIL
msg.preamble = 'Multipart message.\n'
part = MIMEText(content)
msg.attach(part)
if attachment:
part = MIMEApplication(open(attachment, "rb").read())
part.add_header('Content-Disposition', 'attachment', filename=filename)
msg.attach(part)
mailer = SMTP_SSL(config.SMTP_SERVER, config.SMTP_PORT)
# mailer.ehlo()
# mailer.starttls()
mailer.login(config.USERNAME, config.PASSWORD)
mailer.set_debuglevel(1)
mailer.sendmail(msg['From'], msg['To'].split(', '), msg.as_string())
mailer.close()
开发者ID:ankitjain87,项目名称:anyclean,代码行数:26,代码来源:util.py
示例17: sendEmail
def sendEmail( destination, subject, content ):
# don't try this if we are offline
if not internet_on(): return
SMTPserver = 'smtp.gmail.com'
sender = '[email protected]'
USERNAME = "raspitf1"
PASSWORD = "jesuslovesme316"
# typical values for text_subtype are plain, html, xml
text_subtype = 'plain'
from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
# from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
from email.mime.text import MIMEText
try:
msg = MIMEText(content, text_subtype)
msg['Subject']= subject
msg['From'] = sender # some SMTP servers will do this automatically, not all
conn = SMTP(SMTPserver)
conn.set_debuglevel(False)
conn.login(USERNAME, PASSWORD)
try:
conn.sendmail(sender, destination, msg.as_string())
finally:
conn.close()
except Exception as e:
errmsg = str(traceback.format_exception( *sys.exc_info() ));
Logger.info( "error when trying to send email: " + errmsg );
sys.exit( "mail failed; %s" + errmsg ) # give a error message
开发者ID:matthiku,项目名称:buildingAutomationBackend,代码行数:35,代码来源:libFunctions.py
示例18: sendEmail
def sendEmail(text, email_class, identity_dict, email_dict, state, solved_pq = False):
retries, count = 3, 0
while count < retries:
try:
message = composeMessage(text, email_class, identity_dict, email_dict, state, solved_pq)
own_addr = identity_dict['Email']
own_name = ' '.join([identity_dict['First_name'], identity_dict['Last_name']])
destination_addr = email_dict['Reply-To']
text_subtype = 'plain'
mime_msg = MIMEText(message, text_subtype)
mime_msg['Subject'] = composeSubject(email_dict)
mime_msg['From'] = own_name + '<' + own_addr + '>'
if destination_addr in getIdentityEmails():
break
mime_msg['To'] = destination_addr
server_addr = identity_dict['SMTP']
conn = SMTP_SSL(server_addr)
conn.set_debuglevel(False)
conn.login(identity_dict['Username'], identity_dict['Password'])
try:
conn.sendmail(own_addr, destination_addr, mime_msg.as_string())
finally:
print "Send email!"
conn.close()
syncGuardian(mime_msg, identity_dict)
except Exception:
count += 1
continue
pq_status, pq_result = hasPQ(text), None
if pq_status:
pq_result = hasPQ(text).values()[0]
return {'Date': time.ctime(), 'Sender': own_addr, 'Receiver': destination_addr, 'Subject': composeSubject(email_dict), 'Body': message, 'First_name': identity_dict['First_name'], 'Last_name': identity_dict['Last_name'], 'Origin': 'SYSTEM', 'PQ': pq_result}
return None
开发者ID:419eaterbot,项目名称:bot,代码行数:33,代码来源:responder.py
示例19: sendmail
def sendmail(to, app, attach0=False, attach1=False):
from smtplib import SMTP_SSL as SMTP
from email.MIMEText import MIMEText
destination = [to]
# read attach
contentattach = ''
if attach0 and not os.stat("%s" % attach0).st_size == 0:
fp = open(attach0,'rb')
contentattach += '------------------ Error begin\n\n'
contentattach += fp.read()
contentattach += '\n------------------ Error end'
fp.close()
if attach1 and not os.stat("%s" % attach1).st_size == 0:
fp = open(attach1,'rb')
contentattach += '\n\n------------------ Success begin\n\n'
contentattach += fp.read()
contentattach += '\n------------------ Success end'
fp.close()
msg = MIMEText(contentattach, 'plain')
msg['Subject'] = "Mr.Script %s" % app
msg['From'] = sender
try:
conn = SMTP(smtpserver)
conn.set_debuglevel(False)
conn.login(username, password)
conn.sendmail(sender, destination, msg.as_string())
conn.close()
except:
print ' *** Error trying send a mail. Check settings.'
开发者ID:teagom,项目名称:mr-robot,代码行数:35,代码来源:external.py
示例20: send_email
def send_email(content):
if content == "":
return False
destination = [DESTINATION]
# typical values for text_subtype are plain, html, xml
text_subtype = 'plain'
from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
from email.mime.text import MIMEText
try:
msg = MIMEText(content, text_subtype, "utf-8")
msg['Subject'] = SUBJECT_EMAIL
msg['From'] = YA_USER
msg['To'] = DESTINATION
conn = SMTP(SMTP_SERVER)
conn.set_debuglevel(False)
conn.login(YA_USER, YA_PASS)
stat = False
try:
conn.sendmail(YA_USER, destination, msg.as_string())
stat = True
finally:
conn.close()
except Exception, exc:
pass
开发者ID:AntonMezhanskiy,项目名称:backuper1c,代码行数:30,代码来源:app.py
注:本文中的smtplib.SMTP_SSL类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论