Example #1
0
 def _smtp_client(self):
     try:
         smtp = TornadoSMTP(host=self.smtp_server, port=self.smtp_port, use_ssl=self.use_ssl)
         yield smtp.login(user=self.smtp_user, password=self.smtp_password)
         return smtp, ''
     except Exception as e:
         log.warning(e)
         return None, e
def send_email(to_email, subject, html_body):
    smtp = TornadoSMTP(SMTP_SERVER, SMTP_PORT)
    if SMTP_USERNAME and SMTP_PASSWORD:
        yield smtp.starttls()
        yield smtp.login(SMTP_USERNAME, SMTP_PASSWORD)

    msg = EmailMessage()
    msg['Subject'] = subject
    msg['To'] = to_email
    msg['From'] = FROM_EMAIL
    msg.add_header('Content-Type', 'text/html')
    msg.set_payload(html_body)

    yield smtp.send_message(msg)
Example #3
0
def sendConfirmEmail(user_email, password):
    print('Sending Email')
    smtp_client = TornadoSMTP('smtp.mailgun.org')
    yield smtp_client.starttls()
    yield smtp_client.login(smpt_login, smpt_password)

    # MIME Generation
    msg = MIMEMultipart('alternative')
    msg['Subject'] = "Your Key To Ashioto!"
    msg['From'] = smpt_login
    msg['To'] = user_email

    # Email Body
    text = "This is an email to activate your Ashioto Analytics account"
    html = '''\
        <html>
        <head></head>
        <body>
        <p>Hey,<br>
        Your account for Ashioto analytics has been created.<br>
        Your password is: ''' + password + '''<br>
        If any assistance is needed, please contact [email protected]<br>
        Proceed to Ashioto dashboard by logging in : <a href=http://''' + serverhost + '''/login>Log in</a></body></html>'''
    part1 = MIMEText(text, 'plain')
    part2 = MIMEText(html, 'html')
    msg.attach(part1)
    msg.attach(part2)
    yield smtp_client.send_message(msg)
    yield smtp_client.quit()
Example #4
0
    def send_email(self, email, link):
        smtp = TornadoSMTP('smtp-mail.outlook.com')
        yield smtp.starttls()
        yield smtp.login('*****@*****.**', 'eo%Y0pOTmJ%8lG$F9qfT')

        msg = EmailMessage()
        msg['Subject'] = 'Reset Password for RISHA CAR'
        msg['To'] = email
        msg['From'] = '*****@*****.**'
        msg.set_content('reset your password:\n ' + link)
        smtp.send_message(msg)
        print('done')
Example #5
0
    async def report(cls, content, error_track):
        """
        发送错误邮件
        :param content: 邮件内容
        :param error_track: 错误信息
        :return:
        """
        timestamps_now = date_utils.timestamps_now()
        if cls.send_time + 1800 <= timestamps_now:
            logger.info('send report message. error: %s', error_track)
            # 发送邮件
            smtp = TornadoSMTP(cls.smtp_server, use_ssl=True)
            # await smtp.starttls()
            await smtp.login(cls.smtp_account, cls.smtp_pass)

            msg = EmailMessage()
            msg['Subject'] = '[{}]Task error.'.format(cls.report_server)
            msg['To'] = cls.report_to
            msg['From'] = cls.report_from
            msg.set_content(error_track, 'html', 'utf-8')

            await smtp.send_message(msg)

            cls.send_time = timestamps_now
Example #6
0
 def get_smtp_client(self):
     smtp = TornadoSMTP(SMTP_SERVER)
     yield smtp.starttls()
     yield smtp.login(SMTP_USER, SMTP_PASSWORD)
     return smtp
Example #7
0
 def get_smtp_client(self):
     config = self.settings['smtp_config']
     smtp = TornadoSMTP(config['host'])
     yield smtp.starttls()
     yield smtp.login(config['user'], config['password'])
     return smtp
Example #8
0
 def get_smtp_client(self):
     smtp = TornadoSMTP(SMTP_SERVER)
     yield smtp.starttls()
     yield smtp.login(SMTP_USER, SMTP_PASSWORD)
     return smtp