diff --git a/app/dashboard/views/setting.py b/app/dashboard/views/setting.py index 50699628..b9af1e0b 100644 --- a/app/dashboard/views/setting.py +++ b/app/dashboard/views/setting.py @@ -315,6 +315,15 @@ def setting(): return redirect(url_for("dashboard.setting")) Session.commit() flash("Your preference has been updated", "success") + elif request.form.get("form-name") == "sender-header": + choose = request.form.get("enable") + if choose == "on": + current_user.include_header_email_header = True + else: + current_user.include_header_email_header = False + Session.commit() + flash("Your preference has been updated", "success") + return redirect(url_for("dashboard.setting")) elif request.form.get("form-name") == "export-data": return redirect(url_for("api.export_data")) elif request.form.get("form-name") == "export-alias": diff --git a/app/models.py b/app/models.py index 4c05683d..0b721825 100644 --- a/app/models.py +++ b/app/models.py @@ -450,6 +450,11 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle): server_default=BlockBehaviourEnum.return_2xx.name, ) + # to keep existing behavior, the server default is TRUE whereas for new user, the default value is FALSE + include_header_email_header = sa.Column( + sa.Boolean, default=False, nullable=False, server_default="1" + ) + @property def directory_quota(self): return min( diff --git a/email_handler.py b/email_handler.py index 3f36eabf..525a30f9 100644 --- a/email_handler.py +++ b/email_handler.py @@ -801,7 +801,8 @@ def forward_email_to_mailbox( add_or_replace_header(msg, headers.SL_DIRECTION, "Forward") msg[headers.SL_EMAIL_LOG_ID] = str(email_log.id) - msg[headers.SL_ENVELOPE_FROM] = envelope.mail_from + if user.include_header_email_header: + msg[headers.SL_ENVELOPE_FROM] = envelope.mail_from # when an alias isn't in the To: header, there's no way for users to know what alias has received the email msg[headers.SL_ENVELOPE_TO] = alias.email diff --git a/migrations/versions/2022_022512_4729b7096d12_.py b/migrations/versions/2022_022512_4729b7096d12_.py new file mode 100644 index 00000000..9800b92b --- /dev/null +++ b/migrations/versions/2022_022512_4729b7096d12_.py @@ -0,0 +1,29 @@ +"""empty message + +Revision ID: 4729b7096d12 +Revises: 9282e982bc05 +Create Date: 2022-02-25 12:11:10.991810 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '4729b7096d12' +down_revision = '9282e982bc05' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('include_header_email_header', sa.Boolean(), server_default='1', nullable=False)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'include_header_email_header') + # ### end Alembic commands ### diff --git a/templates/dashboard/setting.html b/templates/dashboard/setting.html index 41ec8855..da0b1097 100644 --- a/templates/dashboard/setting.html +++ b/templates/dashboard/setting.html @@ -520,6 +520,30 @@ +
+
+
Include original sender in email headers +
+
+ SimpleLogin forwards emails to your mailbox from the reverse-alias and not from the original sender address.
+ If this option is enabled, the original sender addresses is stored in the email header X-SimpleLogin-Envelope-From. + You can choose to display this header in your email client.
+ As email headers aren't encrypted, your mailbox service can know the sender address via this header. +
+
+ + +
+ + +
+ + +
+
+
+
Alias Import