# Sending Emails Source: https://kart.bnomei.com/docs/guides/sending-emails Updated: 2025-08-08T14:08:50+00:00 Summary: Optimize Kirby CMS email delivery: choose third-party SMTP services, configure env files, test with MailHog, BIMI icons & build responsive emails with MJML. ## Third-party services Usually, your host's SMTP server is very limited in sending emails. In addition, you will have a very high risk of your email landing in your members' spam folders since certification of authenticity does not back it up. Unless you have a very good reason not to, I suggest using any third-party service to send emails you feel comfortable using. Their services vary greatly, and their pricing is based on the email volume. Suggestions, some have their own Kirby CMS plugins for additional functionality: - [Postmark](https://postmarkapp.com/) - [Resend](https://resend.com/) - [Mailchimp](https://mailchimp.com/) - [Mailjet](https://www.mailjet.com/) - [Mailersend](https://www.mailersend.com) - [Rapidmail](https://www.rapidmail.de) - [SendGrid](https://sendgrid.com) My recommendation would be to use a `.env` file to store your credentials and use the `ready`-hook to apply the values once the [dotenv plugin](https://github.com/bnomei/kirby3-dotenv) has them loaded. Path: site/config/config.my-production-server.com.php Code (php): ``` [ 'methods' => ['code', 'magic-link'], 'challenge' => [ 'email' => [ 'from' => 'myverifiedsender@mydomain.com', 'fromName' => 'My Name', ] ] ], 'ready' => function () { return [ 'email' => [ 'transport' => [ 'type' => 'smtp', 'host' => 'smtp.postmarkapp.com', 'port' => 587, 'security' => true, 'auth' => true, 'username' => env('POSTMARK_USERNAME'), 'password' => env('POSTMARK_PASSWORD'), ], ], ]; }, ]; ``` > In the case of Postmark, you will need to create a [SMTP configuration](https://postmarkapp.com/developer/user-guide/send-email-with-smtp) for your broadcast channel. ## Testing Emails You could use tools like the free [Mailhog](https://github.com/mailhog/MailHog) or paid ones like [HELO](https://usehelo.com/) or [HERD Pro](https://herd.laravel.com/) to catch emails sent using your local SMTP server. If you need to test emails on an online staging server, consider [Mailtrap](https://mailtrap.io/) or similar alternatives. The configuration for all of them is very similar, only differing in set config values. Path: site/config/config.php Code (php): ``` [ 'transport' => [ 'type' => 'smtp', 'host' => 'localhost', 'port' => 1025, 'security' => false, ], ], // other options ]; ``` ## FavIcon and BIMI You can do two things to get an image displayed for your email sender in the customer's email clients. The simplest is having a `favicon.ico` file at the server's public HTML root matching the same domain. Like emails from `no-reply@example.com` => `https://example.com/favicon.ico` But the support for that is basic at best, and email clients like Gmail switched to [certified BIMI SVG logos](https://bimigroup.org/) a while ago. That will require you to set up SPF, DKIM and DMARC, and a 3rd party service will make this easier. To gain full email client support, you will need to get your logo certified as a verified mark, as explained by the BIMI Group. ## Creating Emails While you could create emails with plain HTML, certain, sometimes unexpected [limitations](https://www.caniemail.com) exist. My suggestion would be to use [MJML](https://mjml.io) (a [plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=mjmlio.vscode-mjml)) in combination with inlined PHP to avoid most of the issues you do not even know could happen yet. There are also online tools, like [Litmus](https://www.litmus.com), available to test your emails on various email clients and operating systems. However, these usually only have paid tiers or short trials. Path: site/mjml/email.mjml Code (xml): ``` ... ``` Path: package.json Code (json): ``` { "scripts": { "mjml": "mjml site/mjml/email.mjml -o site/templates/emails/email.html.php --config.validationLevel skip" }, } ```