How to Send Emails with Mautic and Gmail

Starting with Mautic can be overwhelming, especially because you need to pick an email service provider that will send your emails. Which to choose?

Well, I can understand if you might be hesitant to jump straight into a third-party email service provider.

But what if I told you that you can (within limitations) use your good old Gmail account?

Using Gmail as your mail transport in Mautic can be a choice for testing and sending your first few emails in production.

đź’ˇ
What you'll learn
• Setting up 2-Step verification for Gmail
• Creating a Google app password for Mautic
• Installing and configuring Symfony’s Gmail mailer transport
• Understanding limitations and considerations of using Gmail as your mail transport

Let's get you started.

Setting Up Sending Emails via Gmail with Mautic: A Step-by-Step Guide

To set everything up for your first email, you need to do 3 things:

  1. (Enable 2-step verification and) create an app password in your Google account.
  2. Install the symfony/google-mailer package.
  3. Configure your mailer DSN in Mautic.

Prerequisite: 2-FA and App Password

Before you can use Gmail for sending your emails with Mautic you have to make sure your Gmail account is ready to handle third-party applications like Mautic:

  1. Enable 2-Step verification (if you haven't, already). You can enable it in your Google account settings: https://myaccount.google.com/security
  2. Generate an app password for Mautic to connect with your Google account. Do it here: https://myaccount.google.com/apppasswords

Here's the relevant Google help page: https://support.google.com/accounts/answer/185839.

After you've set that up, you can install Symfony's Gmail mailer.

Install Symfony's Gmail mailer transport

Installing the transport is easy if you installed Mautic via composer. It's a 3-step process:

  1. Install Symfony's Gmail mailer transport via composer.
  2. Clear your Mautic cache.
  3. Reload your Mautic plugins (probably not necessary).
composer require symfony/google-mailer
php bin/console cache:clear
php bin/console mautic:plugins:reload

The last step is to configure the mailer DSN in Mautic:

Configure Your Mailer DSN in Mautic

To configure your mailer DSN in Mautic follow these steps:

  1. Go to Settings > Configure > Email Settings > Mailer DSN.
  2. Set Scheme to gmail (or gmail+smtp; it doesn't matter which one you use).
  3. Enter your email address into the User field: your.email.address@gmail.com.
  4. Use the 16-digit app password you generated earlier for the Password field.
  5. Set Host to default and leave the fields for Port and Path empty.
  6. Save your settings
  7. Try to send a test email to confirm everything is working.
Mautic email settings for using the Gmail mailer transport
Mautic email settings for using the Gmail mailer transport

Behind the scenes, Symfony’s google-mailer connects to Gmail’s SMTP server (smtp.gmail.com) on port 465 using secure TLS encryption.

đź’ˇ
Symfony's Gmail mailer does currently not support XOAUTH2 or the Gmail API.

Troubleshooting Tips

If you encounter issues:

  • Verify that you’re not attempting to use TLS with port 587. This seems to cause issues with PHPMailer: Source.
  • You might be able to enforce a certain encryption type by adding an option to your mailer DSN: encryption=(tls|ssl). I did not test this.

Limitations and Considerations

While Gmail seems perfect for testing and small-scale use, remember it’s not designed for this.

Here are some limitations and considerations to think of when trying to use Gmail:

Sending Limits

Gmail allows you to send a maximum of 500 emails per day. See Gmail's help page Limits for sending & getting mail.

Also, Gmail might temporarily or maybe even permanently suspend your account for some reason.

Professionalism

Using a Gmail address for business communications might seem unprofessional.

It certainly does to me.

A free email provider address simply doesn't project as professional an image as a branded email addresses do.

Compliance Issues

Ensure compliance with data protection regulations when using Gmail, especially in a business context. Consult a data protection officer or an attorney if you're uncertain.

Sender Reputation

If you use Gmail you won't build sender reputation with your sending email address. This might hurt you later.

If you switch to a professional email service provider you might have strict sending limits until they trust you.

Also: Switching from xyz@gmail.com to newsletter@myprofessionalsite.com changes (obviously) your sending address. This sudden change can put your emails in spam or promotional folders.