当前位置: 首页>>代码示例>>Python>>正文


Python SESConnection.send_email方法代码示例

本文整理汇总了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]"],
                           )
开发者ID:hhuuggoo,项目名称:stockwatcher,代码行数:27,代码来源:stockwatcher.py

示例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')
开发者ID:gmc-dev,项目名称:hours,代码行数:32,代码来源:run.py

示例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))
开发者ID:Deimos,项目名称:SolutionNet,代码行数:11,代码来源:functions.py

示例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)
开发者ID:mashproject,项目名称:mashdjangobackend,代码行数:15,代码来源:tasks.py

示例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]'])
开发者ID:8planes,项目名称:langolab,代码行数:20,代码来源:user_notifier.py

示例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))
开发者ID:8planes,项目名称:sponsorabigot,代码行数:21,代码来源:views.py

示例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)
开发者ID:baydinsoftware,项目名称:remindme,代码行数:21,代码来源:sendtest.py

示例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("&nbsp;","")
  textBody = textBody.replace("&rsquo;","'")
  textBody = textBody.replace("&lsquo;","'")
  textBody = textBody.replace("&rdquo;",'"')
  textBody = textBody.replace("&ldquo;",'"')

  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)
开发者ID:baydinsoftware,项目名称:remindme,代码行数:24,代码来源:sendemail.py

示例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)
开发者ID:hhuuggoo,项目名称:efficiently,代码行数:8,代码来源:webflask.py

示例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
开发者ID:messivite,项目名称:python-api-amazon-ses-email-send,代码行数:67,代码来源:amazonMain.py


注:本文中的boto.ses.SESConnection.send_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。