def send_activation_email(user): send_email(f"Activate account at {current_app.config['PRETTY_URL']}", recipients=[user.email], text_body=render_template("email/auth/activate_account.txt", user=user), html_body=render_template("email/auth/activate_account.html", user=user))
def run(self): """Main Daemon Code.""" logger = self.set_logger() while True: if self.is_inactive(): send_email("Service '%s' is DOWN." % self.name) self.resurrect_service(logger) time.sleep(self.wait)
def send_password_reset_email(user): token = user.get_reset_password_token() send_email(f"Password reset at {current_app.config['PRETTY_URL']}.", recipients=[user.email], text_body=render_template("email/auth/reset_password.txt", user=user, token=token), html_body=render_template("email/auth/reset_password.html", user=user, token=token))
def email(): form_data = request.form name = form_data['name'] email = form_data['email'] message = form_data['message'] try: mailing.send_email(name=name, email=email, message=message) return render_template('main.html') except Exception as e: raise e
def send_error_email(code, error, trace): form = filtered_form() send_email( f"Error: {code}; {current_app.config['PRETTY_URL']} {datetime.utcnow().strftime('%d-%m-%Y, @%H:%M:%S')}", recipients=[current_app.config["ERROR_EMAIL"]], text_body=render_template("email/error/trace.txt", status_code=code, error=error, trace=trace, form=form), html_body=render_template("email/error/trace.html", status_code=code, error=error, trace=trace, form=form))
def endpoint(): if request.method == 'POST': dataJson = request.get_json(request.data) try: email = dataJson['email'] number = dataJson['number'] data = Data(email, number) db.session.add(data) db.session.commit() except: return jsonify('wrong data'), 400 average_number = db.session.query(func.avg(Data.number)).scalar() send_email(email, number, round(average_number, 1)) return jsonify(dataJson), 200
def one_day(): conn = DBConnect() # 네이버 뉴스 크롤링 (하루에 한 번) pageCrawl(conn) # 은행연합회 크롤링 (하루에 한 번) bankgroup_crawling(conn) # 이메일 send_email(conn) print("이미지 생성 완료") # 이메일 체크 유저 메일 전송 send_user_list(conn) conn.close()
def resurrect_service(self, logger): attempt = 0 while attempt <= self.attempts and self.is_inactive(): attempt += 1 logger.error('Service "%s" is down. Trying to start. ' 'Attempt nr %s' % (self.name, str(attempt))) subprocess.Popen(["service", self.name, "start"], stdout=subprocess.PIPE) time.sleep(self.interval) if self.is_inactive(): logger.error('Failed to resurrect service "%s"' % self.name) send_email("Service '%s' failed to start after %s ." % (self.name, str(attempt))) else: logger.info('Ressurection mission for service "%s" ' 'was successfull after %s attempt(s).' % (self.name, str(attempt))) send_email("Service '%s' successfuly started after %s " "attempt(s)" % (self.name, str(attempt)))
def send_password_changed_email(): send_email(f"Password changed at {current_app.config['PRETTY_URL']}.", recipients=[current_user.email], text_body=render_template("email/auth/password_changed.txt"), html_body=render_template("email/auth/password_changed.html"))