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


Python Mailer.send_immediately方法代码示例

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


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

示例1: email

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
def email(subject=None, recipients=None, body=None):
    mailer = Mailer(host='192.168.101.5')
    message = Message(subject=subject,
                      sender='[email protected]',
                      recipients=recipients,
                      html=body)

    mailer.send_immediately(message)
开发者ID:msabramo,项目名称:Doula,代码行数:10,代码来源:notifications.py

示例2: test_send_immediately_and_fail_silently

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
    def test_send_immediately_and_fail_silently(self):

        from pyramid_mailer.mailer import Mailer
        from pyramid_mailer.message import Message

        mailer = Mailer()

        msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")

        mailer.send_immediately(msg, True)
开发者ID:DerRechner,项目名称:pyramid_mailer,代码行数:12,代码来源:tests.py

示例3: profile

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
def profile(request):
    """
    View profile page.
    """
    user = User.get(request.session['login'])

    if request.method =='POST':

        flashError = "Sorry dude : wrong password"

        if not request.POST['initPassword'].strip():
            request.session.flash('No password provided')
            return {'user':user}


        elif not bcrypt.hashpw(request.POST['initPassword'].encode('utf-8'), user.password) == user.password:
            request.session.flash(flashError)
            return {'user':user}

        if request.POST['submitDelete']:
            mailer = Mailer()
            message = Message(subject="Account deleted",
                             sender=settings['mail_from'],
                             recipients=[user.mail],
                             body="Your account have been deleted")
            mailer.send_immediately(message, fail_silently=False)
            user.delete()
            request.session.delete()
            return HTTPFound(location=request.route_path('home'))

        if request.POST['newPassword'].strip():
            if request.POST['newPassword'] == request.POST['confirmPassword']:
                password = bcrypt.hashpw(request.POST['newPassword'].encode('utf-8'), bcrypt.gensalt())
                user.password = password
            else:
                request.session.flash(u"Password not confirm")
                return {'user' : user}

        user.name = request.POST['name']
        user.description = request.POST['description']
        user.mail = request.POST['email']
        user.save()
        request.session.flash(u"Modification saved !")
    return {'user':user}
开发者ID:cyplp,项目名称:wsgiwar2013,代码行数:46,代码来源:views.py

示例4: test_send_immediately_multipart

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
    def test_send_immediately_multipart(self):

        from pyramid_mailer.mailer import Mailer
        from pyramid_mailer.message import Message

        mailer = Mailer()

        utf_8_encoded = b('mo \xe2\x82\xac')
        utf_8 = utf_8_encoded.decode('utf_8')

        text_string = utf_8
        html_string = '<p>'+utf_8+'</p>'

        msg = Message(subject="testing",
                      sender="[email protected]",
                      recipients=["[email protected]"],
                      body=text_string,
                      html=html_string)

        mailer.send_immediately(msg, True)
开发者ID:lorenzogil,项目名称:pyramid_mailer,代码行数:22,代码来源:tests.py

示例5: test_send_immediately_and_fail_silently

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
    def test_send_immediately_and_fail_silently(self):

        from pyramid_mailer.mailer import Mailer
        from pyramid_mailer.message import Message

        mailer = Mailer(host="localhost", port="28322")

        msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")

        result = mailer.send_immediately(msg, True)
        self.assertEqual(result, None)
开发者ID:rpatterson,项目名称:pyramid_mailer,代码行数:13,代码来源:tests.py

示例6: submitSignup

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send_immediately [as 别名]
def submitSignup(request):
    """
    Action on submit page.
    """
    try:
        User.get(request.POST['login'])
    except couchdbkit.exceptions.ResourceNotFound:
        pass
    else:
        request.session.flash(u"Username already exist")
        return HTTPFound(location=request.route_path('signup'))

    if not request.POST['password'].strip():
        request.session.flash(u"You realy need a password")
        return HTTPFound(location=request.route_path('signup'))

    if not len(request.POST['password'].strip()) >= 8:
        request.session.flash(u"Password must have at least 8 characters")
        return HTTPFound(location=request.route_path('signup'))

    if request.POST['password'] == request.POST['confirmPassword']:
        password = bcrypt.hashpw(request.POST['password'].encode('utf-8'),
                                 bcrypt.gensalt())

        user = User(password=password,
                    name=request.POST['name'],
                    description=request.POST['description'],
                    mail=request.POST['email'],
                    random=random.randint(1,1000000000),
                    checked = False
                    )
        user._id = request.POST['login']
        user.save()

        if hasattr(request.POST['avatar'], 'filename'):
            tmph, originImage = tempfile.mkstemp(dir=settings['tmp'], \
                                                 suffix="original")
            os.close(tmph)

            tmph, thumbImage = tempfile.mkstemp(dir=settings['tmp'], \
                                                suffix="thumb")
            os.close(tmph)

            with open(originImage, 'wb') as tmp:
                tmp.write(request.POST['avatar'].file.read())

            fullSize = Image.open(originImage)
            fullSize.thumbnail(avatarSize, Image.ANTIALIAS)
            fullSize.save(thumbImage , "JPEG")

            with open(thumbImage, 'rb') as thumb:
                user.put_attachment(thumb, 'avatar')

            os.remove(originImage)
            os.remove(thumbImage)

        confirm_link = request.route_url('checkLogin',
                userid = user._id,
                randomid = user.random)

        mailer = Mailer()
        message = Message(subject="Your subsription !",
                          sender=settings['mail_from'],
                          recipients=[request.POST['email']],
                          body="Confirm the link\n\n%s" % confirm_link)  # TODO add link

        mailer.send_immediately(message, fail_silently=False)

        return {'name': request.POST['name']}

    else:
        return HTTPFound(location=request.route_path('signup'))
开发者ID:cyplp,项目名称:wsgiwar2013,代码行数:74,代码来源:views.py


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