客户服务,发送简单的文本电子邮件,或者使用在邮递员处创建的模板,发送更复杂的电子邮件。
postman_client的Python项目详细描述
客户服务,发送简单的文本电子邮件,或者使用在Postman创建的模板发送更复杂的电子邮件。
要安装:
pip install postman_client
请按照以下示例发送简单电子邮件或带有模板的电子邮件:
**简单电子邮件:**
。models import mail
from postman。client import postman
postman=postman(key='<;您的帐户"公用密钥",机密="<;您的帐户"机密密钥">;")
def send(self):
mail=mail(
收件人列表=[
"foo bar<;foo.bar@gmail.com>;",
"fulano aquino<;fulano.aquino@gmail.com>;",
'<;ciclano.norego@gmail.com>;'
],
message="只是一个测试,如果你想的话就删除。",
来自'u name='beutrano',
来自'u email='beutrano@gmail.com',
subject="just a test"
)
response=self.postman.send(mail)
**模板电子邮件:**
from postman.models导入邮件
from postman.client导入postman
postman=postman(key='<;您的帐户\公用密钥>;',secret='<;您的帐户'&u secret'>;')
mail=mail(
收件人列表=[
'foo bar<;foo.bar@gmail.com>;',
'fulano aquino<;fulano.aquino@gmail.com>;',
'<;ciclano.norego@gmail.com>;'
],
来自'u name='beutrano',
来自'u email='beutrano@gmail.com',
template='test-101',
context={'foobar':true},
每个收件人的上下文={
"foo.bar@gmail.com":{"foo":true},
"fulano.arquino@gmail.com.br":{"bar":true}
},
使用默认主题=true,
使用默认主题=false,
使用tpl_default_name=false
)
响应=self.postman.send_template(mail)
**邮件参数:**
参数-类型-必需-说明
recipient_list-列表-是-所有收件人的列表。所需格式为"name`<;email>;`"或"`<;email>;`"。
subject-string-yes*-电子邮件的主题。*如果您使用模板发送电子邮件并将"使用默认主题"传递为"真",则不需要传递"主题"。
message\text-string-yes*-文本格式电子邮件的"消息"。*仅当您要发送简单的文本电子邮件时才需要。
*如果传递此信息,则"template戋slug"邮递员将忽略模板的HTML。
tags-dict/list-no-"tags"必须是包含键和简单值的字典或包含字符串的列表。
from戋name-string-no*-发件人的姓名。*如果您使用模板发送电子邮件,并将"使用默认名称"传递为"true",则不需要传递"发件人名称"。
from电子邮件-字符串-是*-发件人的电子邮件。*如果您发送带有模板的电子邮件并将"Use_TPL_default_email"作为"true"传递,则不需要传递"from_email"。
template_slug-string-yes*-"template_slug"是模板的slug。*如果要用模板发送电子邮件,请传递此消息。
使用"tpl"默认名称-bool-no*-如果设置为"true",则使用设置为发件人姓名的默认值。
使用"tpl"默认电子邮件-bool-no*-如果设置为"true",则使用设置为发件人姓名的默认值电子邮件。
使用默认主题-bool-否*-如果设置为"true",则使用设置为主题的默认值。
pose_recipients_list-bool-no*-如果设置为"true",则每个收件人都将看到整个收件人列表。
get_text_from_html-bool-no*-如果设置为"true",则邮递员将从HTML模板中提取文本版本。只有当你的模板没有文本版本时才会发生这种情况。
它还将跟踪在电子邮件中单击的任何链接。
context-dict-no-global变量在模板中使用。格式在上面的示例中表示。
context_Per_Recipient-dict-no-variables set for each recipient.格式在上面的示例中表示。
**客户端参数:**
>参数-类型-必需-描述
key-字符串-是-您的帐户在邮递员中的公钥。
secret-字符串-是-您的帐户在邮递员。
fail_silent-bool-no-如果设置为'true',lib将引发异常。默认值"false"。
要安装:
pip install postman_client
请按照以下示例发送简单电子邮件或带有模板的电子邮件:
**简单电子邮件:**
。models import mail
from postman。client import postman
postman=postman(key='<;您的帐户"公用密钥",机密="<;您的帐户"机密密钥">;")
def send(self):
mail=mail(
收件人列表=[
"foo bar<;foo.bar@gmail.com>;",
"fulano aquino<;fulano.aquino@gmail.com>;",
'<;ciclano.norego@gmail.com>;'
],
message="只是一个测试,如果你想的话就删除。",
来自'u name='beutrano',
来自'u email='beutrano@gmail.com',
subject="just a test"
)
response=self.postman.send(mail)
**模板电子邮件:**
from postman.models导入邮件
from postman.client导入postman
postman=postman(key='<;您的帐户\公用密钥>;',secret='<;您的帐户'&u secret'>;')
收件人列表=[
'foo bar<;foo.bar@gmail.com>;',
'fulano aquino<;fulano.aquino@gmail.com>;',
'<;ciclano.norego@gmail.com>;'
],
来自'u name='beutrano',
来自'u email='beutrano@gmail.com',
template='test-101',
context={'foobar':true},
每个收件人的上下文={
"foo.bar@gmail.com":{"foo":true},
"fulano.arquino@gmail.com.br":{"bar":true}
},
使用默认主题=true,
使用默认主题=false,
使用tpl_default_name=false
)
响应=self.postman.send_template(mail)
**邮件参数:**
参数-类型-必需-说明
recipient_list-列表-是-所有收件人的列表。所需格式为"name`<;email>;`"或"`<;email>;`"。
subject-string-yes*-电子邮件的主题。*如果您使用模板发送电子邮件并将"使用默认主题"传递为"真",则不需要传递"主题"。
message\text-string-yes*-文本格式电子邮件的"消息"。*仅当您要发送简单的文本电子邮件时才需要。
*如果传递此信息,则"template戋slug"邮递员将忽略模板的HTML。
tags-dict/list-no-"tags"必须是包含键和简单值的字典或包含字符串的列表。
from戋name-string-no*-发件人的姓名。*如果您使用模板发送电子邮件,并将"使用默认名称"传递为"true",则不需要传递"发件人名称"。
from电子邮件-字符串-是*-发件人的电子邮件。*如果您发送带有模板的电子邮件并将"Use_TPL_default_email"作为"true"传递,则不需要传递"from_email"。
template_slug-string-yes*-"template_slug"是模板的slug。*如果要用模板发送电子邮件,请传递此消息。
使用"tpl"默认名称-bool-no*-如果设置为"true",则使用设置为发件人姓名的默认值。
使用"tpl"默认电子邮件-bool-no*-如果设置为"true",则使用设置为发件人姓名的默认值电子邮件。
使用默认主题-bool-否*-如果设置为"true",则使用设置为主题的默认值。
pose_recipients_list-bool-no*-如果设置为"true",则每个收件人都将看到整个收件人列表。
get_text_from_html-bool-no*-如果设置为"true",则邮递员将从HTML模板中提取文本版本。只有当你的模板没有文本版本时才会发生这种情况。
它还将跟踪在电子邮件中单击的任何链接。
context-dict-no-global变量在模板中使用。格式在上面的示例中表示。
context_Per_Recipient-dict-no-variables set for each recipient.格式在上面的示例中表示。
**客户端参数:**
>参数-类型-必需-描述
key-字符串-是-您的帐户在邮递员中的公钥。
secret-字符串-是-您的帐户在邮递员。
fail_silent-bool-no-如果设置为'true',lib将引发异常。默认值"false"。