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


Python Mail.set_from_name方法代码示例

本文整理汇总了Python中sendgrid.Mail.set_from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.set_from_name方法的具体用法?Python Mail.set_from_name怎么用?Python Mail.set_from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sendgrid.Mail的用法示例。


在下文中一共展示了Mail.set_from_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SGEmailClient

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import set_from_name [as 别名]
class SGEmailClient(object):

	def __init__(self):
		self.email_config = SendGridConfiguration.objects.all()[:1].get()
		self.sg = SendGridClient(self.email_config.api_key)
		self.message = Mail()
		self.message.set_from(self.email_config.email_from)
		self.message.set_from_name(self.email_config.email_from_name)
		self.message.set_subject(self.email_config.email_subject)

	def send_report_email(self, email, report):
		template_config = TemplateReport.objects.all()[:1].get()
		user = get_object_or_404(User, pk=email)
		logger.info(user)
		html = unicode(template_config.html_template).format(
			user_name=user.first_name,
		)
		self.message.add_to(user.email)
		self.message.add_to_name(user.first_name)
		self.message.set_html(html)

		if report['report']:
			self.message.add_attachment_stream(
				report['name'] , report['report']
			)

		status, msg = self.sg.send(self.message)
		logger.info('{0} - {1}'.format(status, msg))
开发者ID:roofcat,项目名称:ivr-support,代码行数:30,代码来源:sendgrid_client.py

示例2: EmailClient

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import set_from_name [as 别名]
class EmailClient(object):

    def __init__(self):
        self.sg = SendGridClient(SG_API_KEY)
        self.message = Mail()
        self.message.set_from(SG_FROM)
        self.message.set_from_name(SG_FROM_NAME)

    def send_sg_email(self, correo):
        # valores de envío
        self.message.add_to(correo.correo)
        self.message.add_to_name(correo.nombre_cliente)
        self.message.set_subject(correo.asunto)
        self.message.set_html(correo.html)
        # valores personalizados
        unique_args = {
            'empresa': correo.empresa,
            'rut_receptor': correo.rut_receptor,
            'rut_emisor': correo.rut_emisor,
            'tipo_envio': correo.tipo_envio,
            'tipo_dte': correo.tipo_dte,
            'numero_folio': correo.numero_folio,
            'resolucion_receptor': correo.resolucion_receptor,
            'resolucion_emisor': correo.resolucion_emisor,
            'monto': correo.monto,
            'fecha_emision': correo.fecha_emision,
            'fecha_recepcion': correo.fecha_recepcion,
            'estado_documento': correo.estado_documento,
            'tipo_operacion': correo.tipo_operacion,
            'tipo_receptor': correo.tipo_receptor,
        }
        self.message.set_unique_args(unique_args)
        # Validacion de adjuntos
        if correo.attachs:
            for adjunto in correo.attachs:
                adj = AttachModel.query(ancestor=adjunto).get()
                self.message.add_attachment_stream(adj.nombre, adj.archivo)
        # enviando el mail
        status, msg = self.sg.send(self.message)
        # imprimiendo respuesta
        logging.info(status)
        logging.info(msg)

    def send_mail_to_user_attach(self, correo):
        # valores de envío
        self.message.add_to(correo['email'])
        self.message.add_to_name(correo['user_name'])
        self.message.set_subject(correo['subject'])
        self.message.set_html(correo['html'])
        if correo['attach']:
            self.message.add_attachment_stream(correo['attach']['name'], correo['attach']['file'])
        status, msg = self.sg.send(self.message)
        # imprimiendo respuesta
        logging.info(status)
        logging.info(msg)
开发者ID:roofcat,项目名称:etracking,代码行数:57,代码来源:mail_client.py

示例3: config_mail

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import set_from_name [as 别名]
def config_mail():
    message = Mail()
    message.add_to("<[email protected]>")
    message.add_to_name("Kumar, Palani")
    message.set_from("[email protected]")
    message.set_from_name("Kavin");
    message.set_subject("Test message.,")
    message.set_text("Test text")
    message.set_html("<i><b>Test HTML</b></i>")
    message.set_replyto("[email protected]")
    message.set_date(rfc822.formatdate())
    return message
开发者ID:kapalani,项目名称:test-sendgrid-api,代码行数:14,代码来源:test.py

示例4: send_email

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import set_from_name [as 别名]
def send_email(subject='Test email', from_email='[email protected]', from_name='D. Goodwin', recipients=['[email protected]'], text_body='Hello from Flask', html_body='Hello from <b>Flask</b>'):
	from sendgrid import SendGridClient, Mail
	api_key = 'm3tr0pl4c3s'
	api_user = 'metroplaces'
	sendgrid = SendGridClient(username=api_user, password=api_key, 
		raise_errors=True,
		host='http://api.sendgrid.com',
		port=80,
		)

	message = Mail()
	message.add_to(recipients)
	message.set_from(from_email)
	message.set_from_name(from_name)
	message.set_subject(subject)
	message.set_text(text_body)
	message.set_html(html_body)

	try:
		sendgrid.send(message)
	except Exception as e:
		print "fail: %s" %(e)
开发者ID:LACMTA,项目名称:places,代码行数:24,代码来源:extensions.py


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