diff --git a/app/.pre-commit-config.yaml b/app/.pre-commit-config.yaml index 60c43ee..2da4462 100644 --- a/app/.pre-commit-config.yaml +++ b/app/.pre-commit-config.yaml @@ -21,3 +21,4 @@ repos: - id: djlint-jinja files: '.*\.html' entry: djlint --reformat + diff --git a/app/app/mail_sender.py b/app/app/mail_sender.py index 2705ddd..dd143d7 100644 --- a/app/app/mail_sender.py +++ b/app/app/mail_sender.py @@ -17,7 +17,7 @@ from attr import dataclass from app import config from app.email import headers from app.log import LOG -from app.message_utils import message_to_bytes +from app.message_utils import message_to_bytes, message_format_base64_parts @dataclass @@ -173,8 +173,12 @@ class MailSender: self._save_request_to_unsent_dir(send_request) return False - def _save_request_to_unsent_dir(self, send_request: SendRequest): - file_name = f"DeliveryFail-{int(time.time())}-{uuid.uuid4()}.{SendRequest.SAVE_EXTENSION}" + def _save_request_to_unsent_dir( + self, send_request: SendRequest, prefix: str = "DeliveryFail" + ): + file_name = ( + f"{prefix}-{int(time.time())}-{uuid.uuid4()}.{SendRequest.SAVE_EXTENSION}" + ) file_path = os.path.join(config.SAVE_UNSENT_DIR, file_name) file_contents = send_request.to_bytes() with open(file_path, "wb") as fd: @@ -256,7 +260,7 @@ def sl_sendmail( send_request = SendRequest( envelope_from, envelope_to, - msg, + message_format_base64_parts(msg), mail_options, rcpt_options, is_forward, diff --git a/app/app/message_utils.py b/app/app/message_utils.py index a5a199b..34f57d4 100644 --- a/app/app/message_utils.py +++ b/app/app/message_utils.py @@ -1,21 +1,42 @@ +import re from email import policy from email.message import Message +from app.email import headers from app.log import LOG +# Spam assassin might flag as spam with a different line length +BASE64_LINELENGTH = 76 + def message_to_bytes(msg: Message) -> bytes: """replace Message.as_bytes() method by trying different policies""" for generator_policy in [None, policy.SMTP, policy.SMTPUTF8]: try: return msg.as_bytes(policy=generator_policy) - except: + except Exception: LOG.w("as_bytes() fails with %s policy", policy, exc_info=True) msg_string = msg.as_string() try: return msg_string.encode() - except: + except Exception: LOG.w("as_string().encode() fails", exc_info=True) return msg_string.encode(errors="replace") + + +def message_format_base64_parts(msg: Message) -> Message: + for part in msg.walk(): + if part.get( + headers.CONTENT_TRANSFER_ENCODING + ) == "base64" and part.get_content_type() in ("text/plain", "text/html"): + # Remove line breaks + body = re.sub("[\r\n]", "", part.get_payload()) + # Split in 80 column lines + chunks = [ + body[i : i + BASE64_LINELENGTH] + for i in range(0, len(body), BASE64_LINELENGTH) + ] + part.set_payload("\r\n".join(chunks)) + return msg diff --git a/app/templates/dashboard/alias_contact_manager.html b/app/templates/dashboard/alias_contact_manager.html index a1fff07..a9b355d 100644 --- a/app/templates/dashboard/alias_contact_manager.html +++ b/app/templates/dashboard/alias_contact_manager.html @@ -50,7 +50,9 @@

This Youtube video can also quickly walk you through the steps: - + How to send emails from an alias

diff --git a/app/templates/dashboard/custom_domain.html b/app/templates/dashboard/custom_domain.html index b967f77..324b291 100644 --- a/app/templates/dashboard/custom_domain.html +++ b/app/templates/dashboard/custom_domain.html @@ -23,7 +23,9 @@ diff --git a/app/templates/dashboard/domain_detail/auto-create.html b/app/templates/dashboard/domain_detail/auto-create.html index 1ad9a08..87f3e66 100644 --- a/app/templates/dashboard/domain_detail/auto-create.html +++ b/app/templates/dashboard/domain_detail/auto-create.html @@ -78,7 +78,7 @@ data-clipboard-text=".*suffix">.*suffix
To test out regex, we recommend using regex tester tool like - https://regex101.com↗ + https://regex101.com↗
diff --git a/app/templates/dashboard/domain_detail/dns.html b/app/templates/dashboard/domain_detail/dns.html index 4fa40dc..6b46fee 100644 --- a/app/templates/dashboard/domain_detail/dns.html +++ b/app/templates/dashboard/domain_detail/dns.html @@ -158,7 +158,7 @@ SPF (Wikipedia↗) + rel="noopener noreferrer">(Wikipedia↗) is an email authentication method designed to detect forging sender addresses during the delivery of the email. @@ -229,7 +229,7 @@ DKIM (Wikipedia↗) + rel="noopener noreferrer">(Wikipedia↗) is an email authentication method @@ -335,7 +335,7 @@ DMARC + rel="noopener noreferrer"> (Wikipedia↗) is designed to protect the domain from unauthorized use, commonly known as email spoofing. diff --git a/app/templates/dashboard/pricing.html b/app/templates/dashboard/pricing.html index e8a31d8..c8bb898 100644 --- a/app/templates/dashboard/pricing.html +++ b/app/templates/dashboard/pricing.html @@ -72,7 +72,7 @@ PGP Encryption
More information on our - + Pricing Page @@ -120,7 +120,7 @@ Upgrade your SimpleLogin account
🔐 Secure payments by - + Paddle
@@ -164,13 +164,13 @@ $4/month
Payment via - + Coinbase Commerce
Currently Bitcoin, Bitcoin Cash, Dai, Ethereum, Litecoin and USD Coin are supported.
- + Yearly billing - Crypto
$30/year diff --git a/app/templates/dashboard/refused_email.html b/app/templates/dashboard/refused_email.html index 9287c6c..996e689 100644 --- a/app/templates/dashboard/refused_email.html +++ b/app/templates/dashboard/refused_email.html @@ -17,7 +17,8 @@
This page shows all emails that are either refused by your mailbox (bounced) or detected as spams/phishing (quarantine) via our anti-phishing program ↗ + target="_blank" + rel="noopener noreferrer">anti-phishing program ↗
  • If the email is indeed spam, this means the alias is now in the hands of a spammer, @@ -26,7 +27,8 @@
  • If the email isn't spam and your mailbox refuses the email, we recommend to create a filter to avoid your mailbox provider from blocking legitimate emails. Please refer to Setting up filter for SimpleLogin emails ↗ + target="_blank" + rel="noopener noreferrer">Setting up filter for SimpleLogin emails ↗
  • If the email is flagged as spams/phishing, this means that the sender explicitly states their emails should respect diff --git a/app/templates/dashboard/setting.html b/app/templates/dashboard/setting.html index 4355057..00a781f 100644 --- a/app/templates/dashboard/setting.html +++ b/app/templates/dashboard/setting.html @@ -73,7 +73,8 @@ Yearly plan subscribed with cryptocurrency which expires on {{ coinbase_sub.end_at.format("YYYY-MM-DD") }}. + target="_blank" + rel="noopener noreferrer"> Extend Subscription
diff --git a/app/templates/dashboard/subdomain.html b/app/templates/dashboard/subdomain.html index 3a2e2c1..f80238d 100644 --- a/app/templates/dashboard/subdomain.html +++ b/app/templates/dashboard/subdomain.html @@ -25,7 +25,7 @@ This feature is only available on Premium plan. + rel="noopener noreferrer"> Upgrade
diff --git a/app/templates/developer/client_details/base.html b/app/templates/developer/client_details/base.html index 178cda4..b26ed65 100644 --- a/app/templates/developer/client_details/base.html +++ b/app/templates/developer/client_details/base.html @@ -33,6 +33,7 @@
Documentation diff --git a/app/templates/developer/client_details/basic_info.html b/app/templates/developer/client_details/basic_info.html index cab4ca1..9f3c902 100644 --- a/app/templates/developer/client_details/basic_info.html +++ b/app/templates/developer/client_details/basic_info.html @@ -10,7 +10,9 @@

Well done!

Please head to our - + documentation to see how to add SIWSL into your app. diff --git a/app/templates/developer/index.html b/app/templates/developer/index.html index 82b1dfd..1381398 100644 --- a/app/templates/developer/index.html +++ b/app/templates/developer/index.html @@ -49,6 +49,7 @@ New website Docs diff --git a/app/templates/discover/index.html b/app/templates/discover/index.html index 55d618b..6dde96b 100644 --- a/app/templates/discover/index.html +++ b/app/templates/discover/index.html @@ -13,7 +13,9 @@

- +
diff --git a/app/templates/emails/_emailhelpers.html b/app/templates/emails/_emailhelpers.html index ee3448d..e5e70fb 100644 --- a/app/templates/emails/_emailhelpers.html +++ b/app/templates/emails/_emailhelpers.html @@ -46,7 +46,7 @@ https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -->
  • Chrome Extension
  • Firefox Add-on
  • Edge Add-on
  • Safari Extension @@ -174,7 +174,7 @@
  • iOS (App Store) @@ -182,14 +182,14 @@
  • Android (Play Store)
  • Android (F-Droid) diff --git a/app/templates/header.html b/app/templates/header.html index a02aa0f..1401d59 100644 --- a/app/templates/header.html +++ b/app/templates/header.html @@ -75,14 +75,17 @@ Help