本文整理汇总了Python中boto.ses.SESConnection.send_email方法的典型用法代码示例。如果您正苦于以下问题:Python SESConnection.send_email方法的具体用法?Python SESConnection.send_email怎么用?Python SESConnection.send_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.ses.SESConnection
的用法示例。
在下文中一共展示了SESConnection.send_email方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ses_notify
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def ses_notify(pricedict, stocks):
print "notify", pricedict, stocks
lines = []
keys = pricedict.keys()
keys.sort()
if stocks:
lines.append("big movers, %s" % ",".join(stocks))
for k in keys:
v = pricedict[k]
lines.append("%s : %.2f" % (k,v))
message = "\n".join(lines)
print message
import json
with open("/home/yata/keys.json") as f:
data = f.read()
keys = json.loads(data)
from boto.ses import SESConnection
connection = SESConnection(
aws_access_key_id=keys["AWS_ACCESS_KEY"],
aws_secret_access_key=keys["AWS_SECRET_KEY"]
)
connection.send_email("[email protected]",
"stock update", message,
["[email protected]", "[email protected]"],
)
示例2: send_email
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def send_email(date_from, date_to, email=config['email']['default_to'], worklogs=None):
worklogs = worklogs or get_worklogs(date_from, date_to)
# put data into weeks
weeks = {}
for date in worklogs:
# add issue date
for worklog in worklogs[date]:
issue, description = get_jira_issue(worklog['task_name'])
if not issue:
worklog['issue'] = worklog['task_name']
worklog['comment'] = ''
continue
worklog['issue'] = '<a href="%s" target="_blank">%s: %s</a>' % (issue.permalink(), str(issue), issue.fields.summary)
worklog['comment'] = description
week = '%i-%02i' % (date.year, date.isocalendar()[1])
if week not in weeks:
weeks[week] = {}
weeks[week][date] = worklogs[date]
html = build_email(weeks, config['email']['template'])
connection = SESConnection(aws_access_key_id=config['email']['aws']['access_key_id'],
aws_secret_access_key=config['email']['aws']['secret_access_key'])
subject = 'Hours report %s - %s' % (date_from.strftime('%m/%d'), date_to.strftime('%m/%d'))
connection.send_email(config['email']['from'], subject, html, email, format='html')
示例3: ses_email
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def ses_email(config, to_address, subject, body):
connection = SESConnection(aws_access_key_id=config['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=config['AWS_SECRET_ACCESS_KEY_ID'])
from_address = '"SolutionNet" <{0}>'.format(config['FROM_EMAIL_ADDRESS'])
connection.send_email(from_address,
str(subject),
str(escape(body)),
str(to_address))
示例4: send_mail_data
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def send_mail_data(subject, body, format):
connection = SESConnection(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
try:
emails = Mail.objects.all().values_list('email', flat=True)
except Mail.DoesNotExist:
emails = []
for i in range(0, len(emails), MAX_MAILS_PER_SEC):
to_addresses = emails[i:(i + MAX_MAILS_PER_SEC)]
connection.send_email(source=DEFAULT_EMAIL_SENDER, subject=subject, body=body,
to_addresses=DEFAULT_EMAIL_SENDER,
bcc_addresses=to_addresses,
format=format)
time.sleep(1)
示例5: notify_user
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def notify_user(user_notification):
email = user_notification.user.email
email_body = _body(user_notification)
email_subject = _subject(user_notification)
if settings.DEBUG:
print("Sending email: {0} with subject: {1} to: {2}".format(
email_string, email_subject, email))
else:
connection = SESConnection(
aws_access_key_id=settings.AWS_ACCESS_KEY,
aws_secret_access_key=settings.AWS_SECRET_KEY)
connection.send_email(
source="[email protected]",
subject=email_subject,
body=email_body,
to_addresses=[email],
format='html',
cc_addresses=['[email protected]'])
示例6: _send_email
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def _send_email(email, amount, confirm_code):
if not settings.DEBUG:
context = {
'confirm_url': 'http://{0}{1}'.format(
Site.objects.get_current().domain,
reverse('main:confirm_pledge', args=[confirm_code])) }
connection = SESConnection(
aws_access_key_id=settings.AWS_ACCESS_KEY,
aws_secret_access_key=settings.AWS_SECRET_KEY)
connection.send_email(
source="[email protected]",
subject="Please confirm your pledge",
body=render_to_string('pledge_email.html', context),
to_addresses=[email],
format='html',
cc_addresses=['[email protected]'])
else:
print('Sent email to {0} about {1} with confirm code {2}'.format(
email, amount, confirm_code))
示例7: handle_noargs
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def handle_noargs(self, **options):
subject = 'hi krista'
fromName = 'krista'
fromAddress = '[email protected]'
toAddressesStr = '[email protected]'
textBody = 'hihihi'
htmlBody = 'body yo yo yo'
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = "" + str(fromName) + " <" + fromAddress + ">"
msg['To'] = toAddressesStr
connection = SESConnection(aws_access_key_id=settings.AWS_ACCESS_KEY,
aws_secret_access_key=settings.AWS_SECRET_KEY)
connection.send_email(fromName + " <" + fromAddress + ">",
subject, body=htmlBody,
to_addresses=toAddressesStr, text_body=textBody,
format="html", return_path=fromAddress)
示例8: send
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def send(subject,body,toAddressesStr,fromName,fromAddress,replacements):
connection = SESConnection(aws_access_key_id=settings.AWS_ACCESS_KEY, aws_secret_access_key=settings.AWS_SECRET_KEY)
###Send Welcome Email
htmlBody = "%s%s%s" % (HEADER,body,END)
textBody = "%s\n\n\n%s" % (strip_tags(body), "Use link below to unsubscribe from these reminders: \n{{unsubscribe}}")
textBody = textBody.replace(" ","")
textBody = textBody.replace("’","'")
textBody = textBody.replace("‘","'")
textBody = textBody.replace("”",'"')
textBody = textBody.replace("“",'"')
for key, value in replacements.iteritems():
textBody = textBody.replace(key,value)
htmlBody = htmlBody.replace(key,value)
subject = subject.replace(key,value)
connection.send_email(fromName + " <" + fromAddress + ">",
subject, body=htmlBody, to_addresses=toAddressesStr,
text_body=textBody, format="html",
return_path=fromAddress)
示例9: send_email
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
def send_email(fromaddr, toaddrs, subject, txtdata):
from boto.ses import SESConnection
connection = SESConnection(
aws_access_key_id=keys["AWS_ACCESS_KEY"],
aws_secret_access_key=keys["AWS_SECRET_KEY"])
connection.send_email(fromaddr, subject, txtdata, toaddrs)
示例10: AmazonSES
# 需要导入模块: from boto.ses import SESConnection [as 别名]
# 或者: from boto.ses.SESConnection import send_email [as 别名]
class AmazonSES(object):
EMPTY_EMAIL = "Email adress parameter is empty"
TEMPLATE_NOT_FOUND = "Email template not found!"
@classmethod
def __init__(self,AWS_KEY,AWS_SECRET_KEY):
self.connection = SESConnection(aws_access_key_id=AWS_KEY, aws_secret_access_key=AWS_SECRET_KEY)
self.mimeType = "text"
def replaceContent(self,content,param):
for k,v in param.iteritems():
content = content.replace(k,v)
return content
def sendEmail(self,email=None,subject=None,param=None,to_addresses=None,templatePath=None):
print email
print templatePath + " sss"
if not self.connection:
raise Exception, 'No connection found'
if templatePath is None:
raise Exception, "Please set to email template!"
if email is None:
result = {"status":"error","msg":self.EMPTY_EMAIL}
result = self.jsonOutput(result)
print result
return result
file = self.isReadFile(templatePath)
if file is not False:
if param is not None:
message = self.replaceContent(file,param)
else:
message = file
else:
result = {"status":"error","msg":self.TEMPLATE_NOT_FOUND}
result = self.jsonOutput(result)
print result
return result
to_addresses = to_addresses
print self.connection.send_email(email, subject, message,to_addresses ,None,None, self.mimeType, None, None)
# template file is readable?
# return string , bool
def isReadFile(self,file):
file = open(file).read()
if file is not None:
return file
else:
return False
#email setting mimeType
# default text
def setMimeType(self,type):
types = ["text","html"]
if type in types:
self.mimeType = type
else:
self.mimeType = "text";
# print jsonOutput function
def jsonOutput(self,dict):
output = json.dumps(dict)
return output