diff --git a/app/dashboard/__init__.py b/app/dashboard/__init__.py index 3d981918..aedd11a1 100644 --- a/app/dashboard/__init__.py +++ b/app/dashboard/__init__.py @@ -17,4 +17,5 @@ from .views import ( mailbox, deleted_alias, mailbox_detail, + refused_email, ) diff --git a/app/dashboard/templates/dashboard/refused_email.html b/app/dashboard/templates/dashboard/refused_email.html new file mode 100644 index 00000000..a42b7ec2 --- /dev/null +++ b/app/dashboard/templates/dashboard/refused_email.html @@ -0,0 +1,39 @@ +{% extends 'default.html' %} + +{% block title %} + Refused Emails +{% endblock %} + +{% set active_page = "setting" %} + +{% block default_content %} +
+

Refused Emails

+ + {% if fels|length == 0 %} +
+ You don't have any refused email. +
+ {% endif %} + + {% for fel in fels %} + {% set refused_email = fel.refused_email %} + {% set forward = fel.forward %} + +
+ From: {{ forward.website_from or forward.website_email }}
+ To: {{ forward.gen_email.email }}
+
+ Sent {{ refused_email.created_at | dt }} +
+ + + View → +
This will download a ".eml" file that you can open in your favorite email client
+ +
+ {% endfor %} + + +
+{% endblock %} \ No newline at end of file diff --git a/app/dashboard/templates/dashboard/setting.html b/app/dashboard/templates/dashboard/setting.html index 01df04ae..b8793376 100644 --- a/app/dashboard/templates/dashboard/setting.html +++ b/app/dashboard/templates/dashboard/setting.html @@ -183,6 +183,25 @@ +
+
+
Refused Emails +
+ When an email sent to your alias is classified as spam or refused by your email provider, + it usually means your alias has been leaked to a spammer.
+ In this case SimpleLogin will keep a copy of this email (so it isn't lost) + and notify you so you can take a look at its content and take appropriate actions.
+ + The emails are deleted in 7 days. + This is an exceptional case where SimpleLogin stores the email. +
+
+ + See refused emails + +
+
+
Export Data diff --git a/app/dashboard/views/refused_email.py b/app/dashboard/views/refused_email.py new file mode 100644 index 00000000..4b5e84db --- /dev/null +++ b/app/dashboard/views/refused_email.py @@ -0,0 +1,30 @@ +from flask import render_template, request +from flask_login import login_required + +from app.dashboard.base import dashboard_bp +from app.models import ForwardEmailLog + + +@dashboard_bp.route("/refused_email", methods=["GET", "POST"]) +@login_required +def refused_email_route(): + # Highlight a refused email + highlight_fel_id = request.args.get("highlight_fel_id") + if highlight_fel_id: + highlight_fel_id = int(highlight_fel_id) + + fels: [ForwardEmailLog] = ForwardEmailLog.query.filter( + ForwardEmailLog.refused_email_id != None + ).all() + + # make sure the highlighted fel is the first fel + highlight_index = None + for ix, fel in enumerate(fels): + if fel.id == highlight_fel_id: + highlight_index = ix + break + + if highlight_index: + fels.insert(0, fels.pop(highlight_index)) + + return render_template("dashboard/refused_email.html", **locals())