New in Symfony 4.4: Notification Emails
The Mime component was introduced in Symfony 4.3 to help you create email messages. In Symfony 4.4 we've improved it with notification emails. These emails are standardized messages used to send notifications to yourself (e.g. a new user signed up, some invoice was paid, etc.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
use Symfony\Bridge\Twig\Mime\NotificationEmail; $email = (new NotificationEmail()) ->from('firstname.lastname@example.org') ->to('email@example.com') ->subject('My first notification email via Symfony') ->markdown(<<<EOF There is a **problem** on your website, you should investigate it right now. Or just wait, the problem might solves itself automatically, we never know. EOF ) ->action('More info?', 'https://example.com/') ->importance(NotificationEmail::IMPORTANCE_HIGH) ;
Now, use the Mailer component to actually send this message and you'll see something like this in your email client:
Notification emails are already styled with a responsive design based on Foundation for Emails 2, but you can override the theme globally or per email.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.