本文整理汇总了Python中mailer.Mailer.login方法的典型用法代码示例。如果您正苦于以下问题:Python Mailer.login方法的具体用法?Python Mailer.login怎么用?Python Mailer.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer.Mailer
的用法示例。
在下文中一共展示了Mailer.login方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendmail
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
def sendmail(mailto, subject, html='', text='', textfile='', htmlfile='', attachments=''):
'''send mail'''
if not mailto:
print 'Error: Empty mailto address.\n'
return
mailto = [sb.strip() for sb in mailto.split(',')]
if attachments:
attachments = [att.strip() for att in attachments.split(',')]
else:
attachments = []
message = Message(From=USERNAME, To=mailto, Subject=subject)
message.Body = text
message.Html = html
message.charset = 'utf8'
try:
if htmlfile:
message.Html += open(htmlfile, 'r').read()
if textfile:
message.Body += open(textfile, 'r').read()
except IOError:
pass
for att in attachments:
message.attach(att)
sender = Mailer(SERVER)
sender.login(USERNAME, PASSWD)
sender.send(message)
示例2: sendMail
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
def sendMail(item, hwp):
sender = Mailer('smtp.gmail.com',use_tls=True)
for to in MAILER_TO :
sender.login(MAILER_USERNAME,MAILER_PASSWORD)
message = Message(From='[email protected]', To=to)
message.Subject = "가정통신문 :%s"%item['title'].encode('utf-8')
message.Html = ""
if hwp:
message.attach(hwp)
sender.send(message)
示例3: send_email
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
def send_email(from_email, to_email_list, subject, html, smtp_host, smtp_port=587, username=None, password=None):
message = Message(From=from_email, To=to_email_list, charset='utf-8')
# Keep from creating threads in gmail...
message.Subject = "{} -- {}".format(subject, datetime.now().strftime('%Y-%m-%dT%H:%M:%S'))
message.Html = html.encode('utf-8')
message.Body = 'See the HTML!'
sender = Mailer(host=smtp_host, port=smtp_port, use_tls=True, usr=username, pwd=password)
if username is not None:
sender.login(username, password)
sender.send(message)
示例4: send_email
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
def send_email(self):
"""Envia el correo"""
sender = Mailer("smtp.gmail.com", 587, True)
sender.login("[email protected]", "90062957564")
try:
sender.send(self.message)
except smtplib.AMTPAuthenticationError as Error:
print(Error)
return False
except IOError as (error_string, error_number):
print(str(error_string) + " " + str(error_number))
return False
示例5: Sender
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
class Sender(object):
"""Communication engine"""
def __init__(self, config):
"""
Loads configuration, and logs in with twitter and mailer
:config: configuration array
"""
self._config = config
self.twitter = Twitter(auth=OAuth(
self._config['twitter']['oauth'][0],
self._config['twitter']['oauth'][1],
self._config['twitter']['oauth'][2],
self._config['twitter']['oauth'][3]
))
self.sender = Mailer('smtp.gmail.com', use_tls=True, port=587)
self.sender.login(self._config['mail']['address'], self._config['mail']['pass'])
def send_mail(self, html):
"""
Send a mail via smtps
"""
message = Message(
From=self._config['mail']['address'], To=self._config['mail']['to'],
Subject=self._config['mail']['subject']
)
message.Html = html
return self.sender.send(message)
def publish_twitter(event, event_url):
"""
Simple twitter status update with the event url and title
"""
return self.twitter.statuses.update(status='%s: %s' %(event, event_url))
示例6: mail_admins
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
def mail_admins(subject, message, fail_silently=False):
"""Send a message to the admins in conf.ADMINS."""
from celery import conf
if not conf.ADMINS:
return
to = ", ".join(admin_email for _, admin_email in conf.ADMINS)
username = conf.EMAIL_HOST_USER
password = conf.EMAIL_HOST_PASSWORD
message = Message(From=conf.SERVER_EMAIL, To=to,
Subject=subject, Body=message)
try:
mailer = Mailer(conf.EMAIL_HOST, conf.EMAIL_PORT)
username and mailer.login(username, password)
mailer.send(message)
except Exception:
if not fail_silently:
raise
示例7: range
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import login [as 别名]
work = Queue.Queue()
i = 0
for x in data:
if i is 0:
pass
i = i + 1
else:
work.put(x)
totalsent = work.qsize()
print totalsent
threads = []
for i in range(2):
thread = threading.Thread(target=sendsend)
thread.start()
threads.append(thread)
print "Waiting"
for thread in threads:
thread.join()
print "Done"
message = Message(From="Jarvis",
To=["[email protected]"],
Subject="Price Comparison")
message.Body = "Message sent to " + str(totalsent) + " customers"
sender = Mailer('smtp.gmail.com',port=587,use_tls=True)
sender.login("[email protected]","[email protected]")
sender.send(message)