def send_fowarded_message(users, from_email, text, to_username="******"): emails = [user.email for user in users] mail.send(emails, "Cornerwise: Received Message", "forwarded", { "text": text, "from": from_email, "to_username": to_username })
def resetpassword(): errors = [] if request.method == 'POST': email = request.form.get('email', '') if not email: errors.append('Email cannot be empty') else: user = User.query.filter_by(email=email).first() if user: passwordreset = PasswordResets.query.filter_by( user_id=user.id).first() if passwordreset: db.session.delete(passwordreset) db.session.commit() passwordReset = PasswordResets( user.id, ''.join( random.choice( '0123456789qwertyuiopasdfghjklzxcvbnm') for i in range(16)), DT.datetime.now() + DT.timedelta(hours=2)) db.session.add(passwordReset) db.session.commit() msg = Message("Password reset BlueGarden", sender='*****@*****.**', recipients=[email]) msg.html = "<b>Click <a href = 'http://127.0.0.1:5000/resetpassword/%s/%s'>here</a> to reset your password</b>" % ( passwordReset.password_reset_token, passwordReset.user_id) mail.send(msg) return redirect(url_for('resetdone')) return render_template("resetpassword.html", errors=errors)
def send_email(self): cleaned = self.cleaned_data contact = self.request.site_config.contact_for_name(cleaned["send_to"]) emails = [] if contact: if "email" in contact: emails = [contact["email"]] elif "group" in contact: emails = group_emails[contact["group"]] if not emails: emails = group_emails(self.request.site_config.group_name) or \ admin_emails() if emails: for email in emails: mail.send(email, "Cornerwise: User Feedback", "user_feedback", cleaned) return True
def send(user, subject, template_name, context=None, content=None): """ Send an email to a user. If there is a SendGrid template id configured for the given template name, create substitutions from `context` so that `-key` in the template is replaced by the value of `key` in `context`. If there is no such SendGrid template, falls back to using a Django template in <templates>/email. """ return mail.send(user.email, subject, template_name, _make_user_context(user, context))
def resetpassword(): errors = [] if request.method == 'POST': email = request.form.get('email', '') if not email: errors.append('Email cannot be empty') else: user = User.query.filter_by(email=email).first() if user: passwordreset = PasswordResets.query.filter_by(user_id=user.id).first() if passwordreset: db.session.delete(passwordreset) db.session.commit() passwordReset = PasswordResets(user.id, ''.join(random.choice('0123456789qwertyuiopasdfghjklzxcvbnm') for i in range(16)), DT.datetime.now() + DT.timedelta(hours=2)) db.session.add(passwordReset) db.session.commit() msg = Message("Password reset BlueGarden", sender='*****@*****.**', recipients=[email]) msg.html = "<b>Click <a href = 'http://127.0.0.1:5000/resetpassword/%s/%s'>here</a> to reset your password</b>" % (passwordReset.password_reset_token, passwordReset.user_id) mail.send(msg) return redirect(url_for('resetdone')) return render_template("resetpassword.html", errors=errors)
def send_fowarded_message(users, from_email, text): emails = [user.email for user in users] mail.send(emails, "Cornerwise: Received Message", "forwarded", { "text": text, "from": from_email })
def send_email(self): send_to = self.cleaned_data["send_to"] email = RECIPIENTS[form_data["send_to"]] mail.send(email, "Cornerwise: User Feedback", "user_feedback", {"text": self.comment, "subject": self.subject})
def send_fowarded_message(users, from_email, text, to_username="******"): emails = [user.email for user in users] mail.send(emails, "Cornerwise: Received Message", "forwarded", {"text": text, "from": from_email, "to_username": to_username})