本文整理汇总了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()
示例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)
示例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)
示例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)
示例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()}
示例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)
示例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)
示例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)