Closed imorland closed 11 months ago
I like this a lot, great job! My only thought: maybe we should have the unsubscribe controller redirect to the settings page, with a payload in the URL that would trigger an alert / popup / etc?
I did consider that at one point, however that would also require the user to be either logged in, or be bounced thru an auth flow before bing able to present their settings.
My understanding for Unsubscribe-List
is that it should ideally be 1-click. Perhaps we can do this by using the one-time token already generated for the unsubscribe to log the user in? 🤔 Then again, that would also be a security risk, as anyone with that email would then be able to access the account (if the token has not already been used).
That's a good point. I think "unsubscribe on click + link to settings page" is a good compromise.
Instead of unsubscribing on the GET request, maybe that page should be a form (autosubmitted via JS), that pings a POST endpoint?
Instead of unsubscribing on the GET request, maybe that page should be a form (autosubmitted via JS), that pings a POST endpoint?
And if JS is disabled/not available in the email client webview/whatever?
Instead of unsubscribing on the GET request, maybe that page should be a form (autosubmitted via JS), that pings a POST endpoint?
And if JS is disabled/not available in the email client webview/whatever?
Then show a button. Most unsubscribe links I've experience ask you to click a button to confirm; the annoying ones are where you need to click a bunch of checkboxes. What I'm proposing is pretty much what's discussed in the comment thread started by @luceos
Yeah, sorry I was having a "moment" 🙈
I'm already working on this, should be ready shortly
Removals, changes & additions
SendRawEmailJob
is removed, and replaced withSendInformationalEmailJob
.Usage example:
Outgoing email format
By setting the
mail_format
totext
, you're instructing Flarum to only send emails in the plain text format, disregarding the HTML version and multipart option. Adjust this setting according to your needs, but it is recommended to leave it at it's default.Notification templates
Flarum now has two types of notifications/emails.
Notification
andInformational
. Informational emails are things like, password confirm, test, etc. Basically an email that does not require (or should not have) an unsubscribe link and are classified as "essential" or "service" mail.For all other emails, this should probably fall into the
Notification
type. These notifications automatically generate an unsubscribe link and this is rendered in the footer of the email (both HTML and plain).For this reason, when constructing
blade
templates for emails, you should extend one of the base types:HTML
@extends('flarum.forum::email.html.notification.base')
@extends('flarum.forum::email.html.information.base')
When rendering content and/or preview content in a HTML template, it must be wrapped in the utility
$formatter->convert($yourContent)
For example:or, for a
Post
object:Plain
@extends('flarum.forum::email.plain.notification.base')
@extends('flarum.forum::email.plain.information.base')
Both templates allow for sectioned data to be rendered. It is no longer required to include the user greeting, this is now contained in a translation key
core.email.greeting
, for example "Hey username".contentPreview
is optional, if your blade template does not provide it, nothing will be rendered in it's template area.content
is always required.Emails now also have a "signoff" section. Here, the translation key
core.email.signoff
by default will render "The {YOUR_FORUM_NAME} team".Should you wish to disable either the greeting or signoff, this can be done on a template by template method:
@extends('flarum.forum::email.html.notification.base', ['greeting' => false, 'signoff' => false])
UnsubsribeToken
MailableInterface
so that notification blueprints return bothplain
andhtml
viewsplain
andhtml
for all notification emails to extend.multipart
,plain
orhtml
emails from the forumraw
emails (email test, forgot password, etc)Screenshots
Example![image](https://github.com/flarum/framework/assets/16573496/ebd74edd-922c-4df2-98c4-04a07e67bf5b)
informational
email (email test):Example![image](https://github.com/flarum/framework/assets/16573496/5fff81ff-f65b-4e19-9263-cf72f5a5f883)
notification
email (desktop):After clicking to unsubscribe from a notification type, the user is asked to confirm:![image](https://github.com/flarum/framework/assets/16573496/d6a29f51-f55c-416b-a698-adc763f010dd)
...
Changes: