Ejemplo n.º 1
0
 def _send(self, email_message):
     if not email_message.recipients():
         return False
     attachments = []
     for attach in email_message.attachments:
         if isinstance(attach, MIMEBase):
             if not self.fail_silently:
                 raise NotImplemented()
             else:
                 return False
         else:
             attachments.append((attach[0], attach[1]))
     try:
         message = EmailMessage()
         message.to = email_message.recipients()
         message.from_addr = email_message.from_email
         message.subject = email_message.subject
         message.body = email_message.body
         message.smtp = self.smtp
         if attachments:
             message.attachments = attachments
         message.send()
     except Error, e:
         if not self.fail_silently:
             raise
         return False
Ejemplo n.º 2
0
 def _send(self, email_message):
     if not email_message.recipients():
         return False
     attachments = []
     for attach in email_message.attachments:
         if isinstance(attach, MIMEBase):
             if not self.fail_silently:
                 raise NotImplemented()
             else:
                 return False
         else:
             attachments.append((attach[0], attach[1]))
     try:
         message = EmailMessage()
         message.to = email_message.recipients()
         message.from_addr = email_message.from_email
         message.subject = email_message.subject
         message.body = email_message.body
         message.smtp = self.smtp
         if attachments:
             message.attachments = attachments
         message.send()
     except Error, e:
         if not self.fail_silently:
             raise
         return False
Ejemplo n.º 3
0
 def q_send(cls, to, subject, html):
     from sae.mail import EmailMessage
     from setting import smtp
     m = EmailMessage()
     m.to, m.subject, m.html = to, subject, html
     m.smtp = smtp
     try:
         m.send()
     except Exception:
         return None
     return 1
Ejemplo n.º 4
0
def html_mail(to, subject, html, smtp):
    em = EmailMessage()
    em.to = to
    em.subject = subject
    em.html = html
    em.smtp = smtp
    em.send()
Ejemplo n.º 5
0
def batchEmailNotify(comment):
    '''
    Send comment mention notification to all given emails.
    '''
    from sae.mail import EmailMessage

    emails = getMentionedEmails(comment.content)

    if emails:
        author_name = comment.author.name

        notification = EmailMessage()
        notification.from_addr = u'My Nook 邮件提醒<%s>' % EMAIL_HOST_USER
        notification.to = emails
        notification.subject = u'您在回复中被提及'
        notification.html = u'''<p>您好:<br></p>
<p>您在 %s 对《 %s 》的评论中被提及了。<br></p>
<p> %s 说:“%s”。<br></p>
<p>要回复该评论、查看完整的对话历史,或该文章下的所有评论,请点击此处:<a href="http://nook.sinaapp.com/blog/post/%s" target="_blank">%s</a>。<br></p>
<p>您收到这封邮件,是因为您曾在 Joker Qyou 的博客( <a href="http://nook.sinaapp.com/blog/" target="_blank">My Nook</a> )中留下过评论。<br>
如果您不想再收到提醒邮件,请<a href="http://nook.sinaapp.com/blog/mail/" target="_blank">点击此处</a>退订。注意:退订后在博客中的任何评论中被提及,您都不会收到提醒邮件。退订之后您可以在同一页面重新订阅。<br>
注意:此提醒邮件是由博客系统自动发出的,请勿直接回复此邮件。<br></p>
<p>Sincerely    Joker Qyou. <br></p>
''' % (comment.author.name, comment.post.title, comment.author.name, comment.content, comment.post.slug, comment.post.title)
        notification.smtp = (
            EMAIL_HOST, 
            EMAIL_PORT, 
            EMAIL_HOST_USER, 
            EMAIL_HOST_PASSWORD, 
            EMAIL_USE_TLS
        )
        notification.send()
Ejemplo n.º 6
0
def send_email(name, phone):
    from sae.mail import EmailMessage
    m = EmailMessage()
    m.to = '*****@*****.**'
    m.subject = ''
    m.html = 'name: %s\nphone: %s' % (name, phone)
    m.smtp = ('smtp.163.com', 25, '*****@*****.**', 'password', 'zxc123')
    m.send()
Ejemplo n.º 7
0
def html_mail(to, subject, html, smtp):
    em = EmailMessage()
    em.to = to
    em.subject = subject
    em.html = html
    em.smtp = smtp
    em.send()
Ejemplo n.º 8
0
def send_mail(Email,Title,Text):
	m = EmailMessage()
	m.to = Email
	m.subject = Title
	m.html = Text
	m.smtp = ('smtp.126.com',25, '*****@*****.**', 'PSW', False)
	m.send()
Ejemplo n.º 9
0
    def _send(self, email_message):
        """A helper method that does the actual sending."""
        if not email_message.recipients():
            return False
        from_email = sanitize_address(email_message.from_email, email_message.encoding)
        recipients = [sanitize_address(addr, email_message.encoding)
                      for addr in email_message.recipients()]
        #print from_email,recipients,"================"
        #print email_message.message().as_string(),"dddddd"
        try:
            #from sae.mail import send_mail
            #send_mail(recipients, "invite", "to tonight's party"
            #          (self.host, self.port, self.username, self.password, self.use_tls))

            from sae.mail import EmailMessage

            m = EmailMessage()
            m.to = recipients
            m.subject = email_message.subject
            m.html = email_message.body
            m.smtp = (self.host, self.port, self.username, self.password, self.use_tls)
            m.send()

            #self.connection.sendmail(from_email, recipients,email_message.message().as_string())
        except:
            if not self.fail_silently:
                raise
            return False
        return True
Ejemplo n.º 10
0
 def send(kwargs):
     m = EmailMessage()
     m.to = kwargs["to"]
     m.subject = kwargs["title"]
     m.html = kwargs["content"]
     m.smtp = sae.smtp
     m.send()
Ejemplo n.º 11
0
    def send(self):
        from sae.mail import EmailMessage

        m = EmailMessage()
        m.to = self.mailto_list[0]
        m.subject = self.subject
        m.html = self.content
        m.smtp = (self.smtp_host, 25, self.smtp_user, self.smtp_pwd, False)
        m.send()
        return True
Ejemplo n.º 12
0
def sendmail(template,template_data,subject,reveivers):
    template = get_template(template)
    msg = template.render(Context(template_data))
    try:
        from sae.mail import EmailMessage
        m = EmailMessage()
        m.to = reveivers
        m.subject = subject
        m.html = msg
        m.smtp = (settings.EMAIL_HOST, settings.EMAIL_PORT, \
                  settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD, settings.EMAIL_USE_TLS)
        m.send()
    except ImportError:
        pass
Ejemplo n.º 13
0
def sendMailfun(email,title,content):
    try:
        logger.info("sendMailfun发送邮件开始,email:%s" % (email))
        m = EmailMessage()
        m.smtp = (smtpSetting["smtp"], smtpSetting["port"], smtpSetting["email"], smtpSetting["password"], smtpSetting["flag"])
        m.to = email
        m.subject = title
        m.html = content
        m.send()
        logger.info("sendMailfun发送邮件结束,email:%s" % (email))
    except Exception,e:
        logger.error("sendMailfun发送邮件失败,e:%s" % (e))
Ejemplo n.º 14
0
    def send(self, this, chunk=None):
        config = self.getConfig()
        if config and "POST" == this.request.method:
            title = this.get_argument("title")
            text = this.get_argument("text")
            if False == "isDev":
                isTLS = config["isTLS"] == "True" and True or False

                m = EmailMessage()
                m.to = config["email"]
                m.subject = title
                m.html = text
                m.smtp = (config["host"], int(config["port"]), config["email"], config["password"], isTLS)
                m.send()
            else:
                print title
                print text

        return {"this": this, "chunk": chunk}
Ejemplo n.º 15
0
def sendmail(template, template_data, subject, reveivers):
    template = get_template(template)
    msg = template.render(Context(template_data))
    try:
        from sae.mail import EmailMessage

        m = EmailMessage()
        m.to = reveivers
        m.subject = subject
        m.html = msg
        m.smtp = (
            settings.EMAIL_HOST,
            settings.EMAIL_PORT,
            settings.EMAIL_HOST_USER,
            settings.EMAIL_HOST_PASSWORD,
            settings.EMAIL_USE_TLS,
        )
        m.send()
    except ImportError:
        pass
Ejemplo n.º 16
0
def send_mail(title, message, to):
	if settings.IS_SAE:
		from sae.mail import EmailMessage
		m = EmailMessage()
		m.to = to
		m.subject = title
		m.html = '<b>%s</b>' % message
		m.smtp = (settings.MY_EMAIL_HOST, 25, settings.MY_EMAIL_HOST_USER, settings.MY_EMAIL_HOST_PASSWORD, False)
		m.send()

	else:	
		msg = MIMEText(message)
		msg['Subject'] = title
		msg['From'] = settings.MY_EMAIL_HOST_USER
		msg['To'] = to

		s = smtplib.SMTP(settings.MY_EMAIL_HOST)
		status = s.login(settings.MY_EMAIL_HOST_USER, settings.MY_EMAIL_HOST_PASSWORD)

		if status[0] == 235:
			s.sendmail(settings.MY_EMAIL_HOST_USER, [to], msg.as_string())

		s.quit()