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


Python Mail.add_bcc方法代码示例

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


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

示例1: index

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import add_bcc [as 别名]
 def index(self):
     if request.method=='GET':
         user_emails = db_session.query(User).filter(User.new_features_subscription == True)
         email_list = []
         for user in user_emails:
             email_list.append(user.email)
             email_list.append(';')
         context = {'user_emails': email_list}
         return self.render('sendemail.html', **context)
     else:
         jsondata = request.get_json(force=True)
         users_send_email_to = db_session.query(User).filter(User.new_features_subscription == True)
         message = Mail()
         message.set_subject(jsondata['subject'].encode("utf8"))
         message.set_text(jsondata['message'].encode("utf8"))
         message.set_from('ANYWAY Team <[email protected]>')
         for user in users_send_email_to:
             message.add_bcc(user.email)
         try:
             status, msg = sg.send(message)
         except SendGridClientError:
             return "Error occurred while trying to send the emails"
         except SendGridServerError:
             return "Error occurred while trying to send the emails"
         return "Email/s Sent"
开发者ID:agamaloni,项目名称:anyway,代码行数:27,代码来源:main.py

示例2: test_send

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import add_bcc [as 别名]
 def test_send(self):
     m = Mail()
     m.add_to('John, Doe <[email protected]>')
     m.set_subject('test')
     m.set_html('WIN')
     m.set_text('WIN')
     m.set_from('[email protected]')
     m.set_asm_group_id(42)
     m.add_cc('[email protected]')
     m.add_bcc('[email protected]')
     m.add_substitution('subKey', 'subValue')
     m.add_section('testSection', 'sectionValue')
     m.add_category('testCategory')
     m.add_unique_arg('testUnique', 'uniqueValue')
     m.add_filter('testFilter', 'filter', 'filterValue')
     m.add_attachment_stream('testFile', 'fileValue')
     url = self.sg._build_body(m)
     url.pop('api_key', None)
     url.pop('api_user', None)
     url.pop('date', None)
     test_url = json.loads('''
         {
             "to[]": ["[email protected]"],
             "toname[]": ["John Doe"],
             "html": "WIN",
             "text": "WIN",
             "subject": "test",
             "files[testFile]": "fileValue",
             "from": "[email protected]",
             "cc[]": ["[email protected]"],
             "bcc[]": ["[email protected]"]
         }
         ''')
     test_url['x-smtpapi'] = json.dumps(json.loads('''
         {
             "sub": {
                 "subKey": ["subValue"]
             },
             "section": {
                 "testSection":"sectionValue"
             },
             "category": ["testCategory"],
             "unique_args": {
                 "testUnique":"uniqueValue"
             },
             "filters": {
                 "testFilter": {
                     "settings": {
                         "filter": "filterValue"
                     }
                 }
             },
             "asm_group_id": 42
         }
         '''))
     
     try:
         self.assertItemsEqual(url, test_url)
     except: # Python 3+
         self.assertCountEqual(url, test_url)
开发者ID:Adomako-Bismark,项目名称:sendgrid-python,代码行数:62,代码来源:test_mail_v2.py

示例3: test_drop_to_header

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import add_bcc [as 别名]
    def test_drop_to_header(self):
        m = Mail()
        m.add_to('John, Doe <[email protected]>')
        m.set_from('[email protected]')
        m.set_subject('test')
        m.set_text('test')
        m.add_bcc('John, Doe <[email protected]>')
        url =  self.sg._build_body(m)

        print url
开发者ID:yred,项目名称:sendgrid-python,代码行数:12,代码来源:__init__.py

示例4: test_drop_to_header

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import add_bcc [as 别名]
 def test_drop_to_header(self):
     smtpapi = "{}"
     m = Mail()
     m.add_to("John, Doe <[email protected]>")
     m.set_from("[email protected]")
     m.set_subject("test")
     m.set_text("test")
     m.add_bcc("John, Doe <[email protected]>")
     url = self.sg._build_body(m)
     self.assertEqual(smtpapi, url["x-smtpapi"])
开发者ID:RekindleInc,项目名称:sendgrid-python,代码行数:12,代码来源:__init__.py

示例5: test_send

# 需要导入模块: from sendgrid import Mail [as 别名]
# 或者: from sendgrid.Mail import add_bcc [as 别名]
    def test_send(self):
        m = Mail()
        m.add_to("John, Doe <[email protected]>")
        m.set_subject("test")
        m.set_html("WIN")
        m.set_text("WIN")
        m.set_from("[email protected]")
        m.set_asm_group_id(42)
        m.add_cc("[email protected]")
        m.add_bcc("[email protected]")
        m.add_substitution("subKey", "subValue")
        m.add_section("testSection", "sectionValue")
        m.add_category("testCategory")
        m.add_unique_arg("testUnique", "uniqueValue")
        m.add_filter("testFilter", "filter", "filterValue")
        m.add_attachment_stream("testFile", "fileValue")
        url = self.sg._build_body(m)
        url.pop("api_key", None)
        url.pop("api_user", None)
        url.pop("date", None)
        test_url = json.loads(
            """
            {
                "to[]": ["[email protected]"],
                "toname[]": ["John Doe"],
                "html": "WIN",
                "text": "WIN",
                "subject": "test",
                "files[testFile]": "fileValue",
                "from": "[email protected]",
                "cc[]": ["[email protected]"],
                "bcc[]": ["[email protected]"]
            }
            """
        )
        test_url["x-smtpapi"] = json.dumps(
            json.loads(
                """
            {
                "sub": {
                    "subKey": ["subValue"]
                },
                "section": {
                    "testSection":"sectionValue"
                },
                "category": ["testCategory"],
                "unique_args": {
                    "testUnique":"uniqueValue"
                },
                "filters": {
                    "testFilter": {
                        "settings": {
                            "filter": "filterValue"
                        }
                    }
                },
                "asm_group_id": 42
            }
            """
            )
        )

        self.assertEqual(url, test_url)
开发者ID:kykocamp,项目名称:sendgrid-python,代码行数:65,代码来源:__init__.py


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