def _user_insert_callback(result, error): if result: logger.debug( 'User data has been inserted to db for user with ' 'facebook id=%s' % data['id'] ) # sending mail to admin message = EmailMessage( 'New user has registered ', '%s: http://facebook.com/%s' % (data['id'], data['id']), self.settings['mail_default_from'], self.settings['new_user_notify_emails'], connection=self.mail_connection ) message.send() if self.settings.get('beta_mode'): self.finish( "Thank your for registration. We will notify you when your account become active." ) return self.set_secure_cookie( "user", tornado.escape.json_encode(str(data['id'])) ) self.redirect(self.reverse_url('recommendations', 'movies')) else: raise tornado.web.HTTPError(500, "Facebook auth failed")
def mail_send(self, to, cc=None, bcc=None, subject='', message='', attachments=None): """ Sends email using GMail account. email_address and gmail_password application settings are required. """ self.require_setting('email_address', 'email sending') def _finish(num): logging.debug('_finish %s' % num) if type(to) is not list: to = StrToList(to) message = EmailMessage( subject = subject, body = message, from_email = self.settings['email_address'], to = to, cc = cc, bcc = bcc, connection = self.__mail_connection ) # message.attach( # filename = '', # content = '' # ) message.send(callback=_finish)
def post(self): def _finish(num): print 'sent %d message(s)' % num self.render("index.html") message = EmailMessage(self.get_argument('subject'), self.get_argument('message'), 'Swahilipot Hub', [self.get_argument('email')], connection=self.mail_connection) message.send() # callback=_finish) self.render("index.html")
def send_email(self, email): try: message = EmailMessage( self._subject, self._message, '*****@*****.**', [email], connection=self.mail_connection ) message.send() except Exception, e: print e
def get(self): def _finish(num): print "sended %d message(s)" % num self.render("index.html") message = EmailMessage( self.get_argument("subject"), # 两封主题如果接近的话会被QQ邮箱忽略 self.get_argument("message"), "*****@*****.**", [self.get_argument("email")], connection=self.mail_connection, ) message.send() # callback=_finish) self.render("index.html")
def sendMail(self, userMail, pngPath): img_data = open(pngPath, 'rb').read() imgAttachment = MIMEImage(img_data, name=os.path.basename(pngPath)) curDate = datetime.now() subject = 'Rendering from ' + str(curDate) msg = 'Rendering from nori.' message = EmailMessage( subject, msg, '*****@*****.**', [userMail], connection=self.mail_connection, attachments=[imgAttachment] ) message.send()
def post(self): def _finish(num): print 'sent %d message(s)' % num self.render("index.html") message = EmailMessage( self.get_argument('subject'), self.get_argument('message'), 'Swahilipot Hub', [self.get_argument('email')], connection=self.mail_connection ) message.send() # callback=_finish) self.render("index.html")
def send_email(self, subject='', body='', to_email=''): message = EmailMessage(subject=subject, body=body, from_email='*****@*****.**', to=[to_email], connection=self.mail_conn) return message
def get_email_captcha(self, to_email, username, captcha, time_out): """ @param to_email: 收件人 @param time_out: 有效时间秒, int类型 """ self.to_email = to_email to_list = [to_email] content = "hao" message = EmailMessage( "email_subject", content, "*****@*****.**", to_list, connection=EmailBackend("202.85.210.130", 25, "*****@*****.**", "smt_email0416", True), ) message.content_subtype = "html" return message
def write_error(self, status_code, **kwargs): logger.info('Error during request!') super(BaseHandler, self).write_error(status_code, **kwargs) logger.info('Sending error report to admins...') if not self.settings['debug']: traceback_data = '\n'.join( [l for l in traceback.format_exception(*kwargs["exc_info"])] ) request_data = '\n'.join( ["%s: %s" % (k, v) for k, v in self.request.__dict__.items()] ) message = EmailMessage( '[Tornado] ERROR %s: %s' % ( kwargs["exc_info"][0], self.request.path ), 'Status code: %s\n \n%s\nRequest data:\n %s' % ( status_code, traceback_data, request_data ), self.settings['mail_default_from'], self.settings['error_report_emails'], connection=self.mail_connection ) message.send()
def send_email(self, email=None, template=None, params=None, from_email=None, reply_to=None): if params and template: message = EmailFromTemplate(self._subject, template, params=params, from_email=from_email, to=[email], reply_to=reply_to, connection=self.mail_connection) else: message = EmailMessage(self._subject, self._message, from_email, [email], connection=self.mail_connection) try: message.send() except Exception, e: print e