示例#1
0
文件: user.py 项目: Runhorn/mailing
 def send_plain_mail(self, receiver, subject, body):
     '''
     User uses Mail class object, receiver and subject strings and body html message
     This method does all the logic script
     create_session method creates SMTP session for the User to login in e-mail acc
     attach_message attaches html body to the message object of mail
     send_mail ends session and sends e-mail to receiver
     '''
     plain_mail = Mail(self, receiver, subject, body)
     plain_mail.create_session()
     plain_mail.attach_message()
     plain_mail.send_mail()
示例#2
0
 def send_mail_with_attachment(self, receiver, subject, body):
     '''
     In body, please notice that signature img is denoted by a tag:
     <img src="cid:signature_image">
     it has to be at the end of html body of mail.
     Method calls other class methods to create objects as image and payload to use in mail.
     Image is a signature image.
     Payload is any attachment to the mail.
     '''
     attachment_mail = Mail(self, receiver, subject, body)
     image = self.create_signature_image_object()
     payload = self.create_attachment_object()
     attachment_mail.message.attach(image)
     attachment_mail.message.attach(payload)
     attachment_mail.create_session()
     attachment_mail.attach_message()
     attachment_mail.send_mail()