How to configure SMTP or Mail Servers with Strapi
January 29, 2025
Strapi is a popular open-source CMS that helps developers build powerful applications quickly. One crucial feature for most applications is the ability to send emails, whether for user notifications, password resets, or other transactional messages. Setting up SMTP (Simple Mail Transfer Protocol) or using a third-party mail provider with Strapi allows your application to reliably handle email communication.Â
Why Use SMTP with Strapi?
Configuring SMTP in Strapi allows you to:
- Enhance Deliverability: Dedicated SMTP services or servers can reduce spam rejections.
- Boost Security: Encryption protocols such as SSL/TLS secure your email data.
- Customize Emails: Configuring SMTP lets you set custom sender addresses and create branded templates.
How to implement SMTP with Strapi
Install the Strapi Email Plugin
The Strapi Email plugin makes it easy to integrate SMTP or third-party providers. First, ensure the plugin is installed using command:
Once installed, this plugin allows Strapi to send emails with custom configurations using SMTP or other email providers.
Configure the SMTP Provider
The email plugin’s configuration file is located in config/plugin.js in file structure. For SMTP setup, you’ll specify details like the SMTP host, port, and authentication credentials.
In config/plugin.js, configure your SMTP settings as follows:
provider: Set this to 'smtp' to specify that we are using SMTP.
providerOptions:
- host: The SMTP server’s hostname (e.g., smtp.gmail.com).
- port: The port number. For standard SMTP, use 587 for TLS or 465 for SSL.
- secure: Set true for SSL connections (port 465), false for TLS (port 587).
- auth:Â SMTP credentials. user is the email address, and pass is the email account password (or an app-specific password for providers like Gmail).
settings:
- defaultFrom: Default sender email address.‍
- defaultReplyTo: Default reply-to email address.
Sending Emails in Strapi
Now that SMTP is configured, you can send emails programmatically within Strapi controllers or services using strapi.plugins['email'].services.email.send.
Here’s an example:
This function sends an email using your SMTP configuration, making it easy to trigger emails from any Strapi logic.
If you need any assistance in Strapi development, feel free to connect with us! We are verified Strapi partners and can help you with everything from setting up email configurations to building fully customized Strapi applications. Whether you’re facing technical challenges or looking to optimize your Strapi setup, our expertise ensures a seamless development experience.
ConclusionÂ
When implementing SMTP with Strapi, there are several additional advanced features you can consider to enhance your email system. From using third-party  providers for scalability, to adding custom templates, queuing jobs for large email volumes, and ensuring robust logging and debugging, these additions will make your email setup more reliable, secure, and flexible.
By implementing these enhancements, you can ensure smooth, professional, and scalable email delivery within your Strapi application.