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


Python Mailer.send方法代码示例

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


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

示例1: ThreadMailer

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send [as 别名]
class ThreadMailer(threading.Thread):
    """
    인덱스 추가/삭제를 위한 쓰레드
    """
    def __init__(self):
        threading.Thread.__init__(self)
        self.queue = Queue.Queue()
        self.mailer = Mailer(host="localhost")
    
    def send(self, msg):
        self.queue.put(msg)
        
    def run(self):

        while True:
            # 큐에서 작업을 하나 가져온다
            msg = self.queue.get()
            self.mailer.send(msg)
            log.info(msg.subject)
            transaction.commit()
            log.info("MAIL COMMITTED!")
            
            # 작업 완료를 알리기 위해 큐에 시그널을 보낸다.
            self.queue.task_done()
    
    def end(self):
        self.queue.join()
开发者ID:theun,项目名称:in.nuribom.com,代码行数:29,代码来源:admin.py

示例2: test_send

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send [as 别名]
    def test_send(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(msg)
开发者ID:rpatterson,项目名称:pyramid_mailer,代码行数:12,代码来源:tests.py

示例3: test_send_without_body

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

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

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

        mailer = Mailer()

        self.assertRaises(InvalidMessage, mailer.send, msg)

        msg.html = "<b>test</b>"

        mailer.send(msg)
开发者ID:kristianbenoit,项目名称:pyramid_mailer,代码行数:17,代码来源:test_message.py

示例4: test_send

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

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

        mailer = Mailer()

        msg = Message(subject="testing",
                      sender="[email protected]",
                      recipients=["[email protected]"],
                      body="test")
        msg.attach(Attachment('test.txt',
                              data=b"this is a test", 
                              content_type="text/plain"))

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

示例5: contato

# 需要导入模块: from pyramid_mailer.mailer import Mailer [as 别名]
# 或者: from pyramid_mailer.mailer.Mailer import send [as 别名]
def contato(request):
    """Contato"""
    # Import smtplib for the actual sending function
    import smtplib
	
    esquema = FormContato().bind(request=request)
    esquema.title = "Entre em contato com o Cuidando"
    form = deform.Form(esquema, buttons=('Enviar',))
    if 'Enviar' in request.POST:
        # Validação do formulário
        try:
            form.validate(request.POST.items())
        except deform.ValidationFailure as e:
            return {'form': e.render()}

        #sender = request.POST.get("email")
        #receivers = ['[email protected]']	
        #message = request.POST.get("assunto")	
				        						
        try:
            #s = smtplib.SMTP( [host [, port [, local_hostname]]] )
            #s = smtplib.SMTP('pop.mail.yahoo.com.br',587)
            #smtpObj.sendmail(sender, receivers, message)	
            #s.quit()			
            #mailer = get_mailer(request)		
            mailer = Mailer()			
            message = Message(
                subject=request.POST.get("assunto"),
                sender= request.POST.get("email"), #"[email protected]",
                recipients=['[email protected]'],
                body=request.POST.get("mensagem")
            )		
            mailer.send(message)	
            transaction.commit() 	
            print "Successfully sent email"
		#except SMTPException:
        except:
            print "Error: unable to send email"		
      
		
        return HTTPFound(location=request.route_url('inicial'))
    else:
        # Apresentação do formulário
        return {'form': form.render()}
开发者ID:COLAB-USP,项目名称:cuidando-experimentos,代码行数:46,代码来源:views.py

示例6: test_bcc_without_recipients

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

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

        msg = Message(subject="testing", sender="[email protected]", body="testing", bcc=["[email protected]"])
        mailer = Mailer()
        msgid = mailer.send(msg)
        response = msg.to_message()

        self.assertFalse("Bcc: [email protected]" in text_type(response))
        self.assertTrue(msgid)
开发者ID:kristianbenoit,项目名称:pyramid_mailer,代码行数:14,代码来源:test_message.py

示例7: send_mail

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

    mailer = Mailer( host='smtp.gmail.com',
                     port=587, #???
                     username='[email protected]',
                     password='1234test',
                     tls=True)

    if request.params.get('email') is not None:
        email = request.params['email']
    else:
        email = "the email does not exist"

    send_topic = 'Welcome to join us for the seminar'
    send_er = '[email protected]'
    send_to = [email]
    send_this = "Thank you for signing up at our website..."

    message = Message( subject = send_topic,
                       sender = send_er,
                       recipients = send_to,
                       body = send_this )

    here = os.path.dirname(__file__)
    att1 = os.path.join(here, 'static','velur1.pdf')
    attachment = Attachment(att1, "image/jpg",
                        open(att1, "rb"))

    message.attach(attachment)

    here = os.path.dirname(__file__)
    att2 = os.path.join(here, 'static','velur2.pdf')
    attachment = Attachment(att2, "image/jpg",
                        open(att2, "rb"))

    message.attach(attachment)

   # mailer.send_immediately(message, fail_silently=False)
    mailer.send(message)
    return Response(email)
开发者ID:IreneBreck,项目名称:cpserver,代码行数:42,代码来源:views.py

示例8: send_mail

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

    mailer = Mailer( host='smtp.gmail.com',
                     port=587, #???
                     username='[email protected]',
                     password='password',
                     tls=True)

    if request.params.get('email') is not None:
        email = request.params['email']
    else:
        email = "the email does not exist"

    send_topic = 'Welcome to join us for the seminar'
    send_er = '[email protected]'
    send_to = [email]
    send_this = "Thank you for signing up at our website..."

    message = Message( subject = send_topic,
                       sender = send_er,
                       recipients = send_to,
                       body = send_this )

    attachment = Attachment("velur1.pdf", "image/jpg",
                        open("velur1.pdf", "rb"))

    message.attach(attachment)

    attachment = Attachment("velur2.pdf", "image/jpg",
                        open("velur2.pdf", "rb"))

    message.attach(attachment)

   # mailer.send_immediately(message, fail_silently=False)
    mailer.send(message)
    return Response(email)
开发者ID:IreneBreck,项目名称:cpserver,代码行数:38,代码来源:cpserver.py


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