GrLdev / GrLdev/Rate-My-Student-Home

Email verification

Open
#45 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Set up a rate-my-student-home email to send emails from, create a verification link lasting 48h that needs to be clicked before a review is shown publically on the website.

Snippet from previous project:
```
# __init__.py
from flask_redmail import RedMail
#Emailer
app.config["EMAIL_HOST"] = email_host
app.config["EMAIL_PORT"] = email_port
app.config['EMAIL_USER'] = email_user
app.config['EMAIL_PASSWORD'] = email_password
class Mailer():
def __init__(self):
self.sender = RedMail(app)


def send_html(self, to, html, subject):
self.sender.send(
subject=subject,
receivers=[to],
html=html
)

mailer = Mailer()

# routes.py
from app import mailer
from itsdangerous import URLSafeTimedSerializer, SignatureExpired

s = URLSafeTimedSerializer("SECRET_KEY_CHANGE_ME")

token = s.dumps(user.email, salt="email-confirm")
confirm_url = url_for("confirm_email", token=token, _external=True)
email_content = render_template("email_accountcreation.html", confirm_url=confirm_url)
mailer.send_html(user.email, email_content, "Registration")

@app.route("/confirm_email/")
def confirm_email(token):
try:
email = s.loads(token, salt="email-confirm", max_age=172800)
except SignatureExpired:
flash("The token is expired!", "danger")

# email_accountcreation.html

Thank you for registering with Toolshare!


Please verify your email by clicking the following link




{{ confirm_url }}


```
In future we can host our own mail server

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.