Add email verification link in clear text, not only HTML (patch included!)
Is your feature request related to a problem? Please describe
After creating a user account or clicking "Use a Login Link" (i.e. Castopod's way of saying Forgot password), the user is sent an email with a verification link. If the email client is text-only, it renders the HTMLized link (<a>
tag with appropriate href
) only as the word "Login", or whatever the string Auth.login
renders in your server's locale.
Problem: The actual verification link URL is not rendered in the text-only version of the email.
Describe the solution you'd like
I suggest to write out the verification link URL so that text-only email clients can display it right away. Otherwise, the user must crawl the (admittedly short) HTML version of the email and extract the URL manually.
Here is a proposed patch to add the link URL in clear text. This is the source file for the welcome email on the develop
branch, and this is the "Login Link" source file. Heads up: this patch adds the spelled-out link URL to the HTML version of the email as well!
--- a/themes/cp_auth/emails/welcome_email.php
+++ b/themes/cp_auth/emails/welcome_email.php
@@ -4,7 +4,8 @@
'numberOfHours' => setting('Auth.welcomeLinkLifetime') / 3600,
]) ?><br /><br />
+ <?= lang('Auth.login') ?>:
<a href="<?= url_to('verify-magic-link') ?>?token=<?= $token ?>">
- <?= lang('Auth.login') ?>
+ <?= url_to('verify-magic-link') ?>?token=<?= $token ?>
</a>
</p>
--- a/themes/cp_auth/emails/magic_link_email.php
+++ b/themes/cp_auth/emails/magic_link_email.php
@@ -1,5 +1,6 @@
<p>
+ <?= lang('Auth.login') ?>:
<a href="<?= url_to('verify-magic-link') ?>?token=<?= $token ?>">
- <?= lang('Auth.login') ?>
+ <?= url_to('verify-magic-link') ?>?token=<?= $token ?>
</a>
</p>
Describe alternatives you've considered
- The problem is a small one. Not fixing it would be fine as well.
- The proposed fix leaves something to be desired (formatting/line breaks, (not) showing the spelled-out URL in the HTML version of the email)
Additional context
Email contents without said patch (Castopod 1.3.3), verification link redacted
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_6448db8096ed30.57904004
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
An account was created for you on ...., click on the login
link below to set your password. The link is valid for 48 hours after this
email was sent.
Login
--B_ALT_6448db8096ed30.57904004
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p>=0A An account was created for you on ...., click on t=
he login link below to set your password. The link is valid for 48 hours af=
ter this email was sent.<br /><br />=0A=0A <a href=3D"https://....=
/cp-auth/login/verify-magic-link?token=....">=0A=
Login </a>=0A</p>
--B_ALT_6448db8096ed30.57904004--
Email contents with patch, verfication link redacted
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_6448e24503a2d4.04340740
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
An account was created for you on ...., click on the login
link below to set your password. The link is valid for 48 hours after this
email was sent.
Login:
https://..../cp-auth/login/verify-magic-link?token=....
--B_ALT_6448e24503a2d4.04340740
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p>=0A An account was created for you on ...., click on t=
he login link below to set your password. The link is valid for 48 hours af=
ter this email was sent.<br /><br />=0A Login:=0A <a href=3D"https://=
/cp-auth/login/verify-magic-link?token=....">=0A https://....
/cp-auth/login/verify-magic-link?token=.... </a>=0A</p>
--B_ALT_6448e24503a2d4.04340740--
Thanks @lebka@github.com for testing the patch!