Skip to content

This feature allows Mautic to send different emails through different mail API keys.

Notifications You must be signed in to change notification settings

1FF/mautic-custom-email-settings

Repository files navigation

Mautic custom email settings plugin

This plugin allows Mautic to switch between different email services - Sparkpost and Sendgrid. You can use different API keys for the supported email providers based on the API Settings and Product settings.

Installation via .zip

  1. Download the master.zip, extract it into the plugins/ directory, and rename the new directory to CustomEmailSettingsBundle.
  2. Check the permissions and ownership of the plugin folder, and change them if needed - they should be the same as for other plugins.
  3. Clear the cache via console command php bin/console cache:clear --env=prod (might take a while) OR manually delete the var/cache/prod directory.

Update

  1. Remove the plugins/CustomEmailSettingsBundle directory.
  2. Download the master.zip, extract it into the plugins/ directory, and rename the new directory to CustomEmailSettingsBundle.
  3. Check the permissions and ownership of the plugin folder, and change them if needed - they should be the same as for other plugins.
  4. Clear the cache via console command php bin/console cache:clear --env=prod (might take a while) OR manually delete the var/cache/prod directory.
  5. Run php bin/console mautic:plugins:install in the root Mautic directory.

Configuration

Choose "Multiple Transport" in Configuration / Email Settings

image

Specify the correct E-mail address to send mail from and add the API key which will be used as default (required).

API Keys settings

In this section you can set transport and API key for each Email (Channels > Emails). Navigate to the Settings Panel on the right. You should see the "Email Api Keys" menu in your settings:

mautic1

In the plugin configuration you can add a different API key for the given mail template or you can leave it blank so that the default API key will be used:

2022-10-03_15-02

Please note:

  • It is important to specify the correct From address for emails, where the custom API key will be used (Channels > Emails > Edit Email > Advanced tab).
  • To delete the already configured API key just clear the "key" field and save it;
  • If no service is chosen, the default email settings will be used;
  • When fresh Mautic setup you need to create at least one email first (Channels > Emails);

Multi-Product settings

In this section you can set transport, API key, and sender parameters to replace the default email settings for each email when it's sending, based on the selected custom field of the Contact (Lead). Select "Multi-Product Settings" on the right Settings panel.

Multi-Product-Settings-Mautic (1)

The name of the custom field can be changed in the plugin's config file, by default it is 'domain'.

For example, part of your contacts has 'domain' "usa.mysuperservice.com" and another part - "uk.mysuperservice.com". You can make two config rows with different email settings for 'usa' and 'uk', and send emails from the selected sender through selected transport to each contact, based on its 'domain' field.

Based on the settings on the screenshot below, when sending an email, it will find contact (lead) in the contacts database and check the contact's 'domain' field. If it includes 'usa', the email params will be changed to the ones indicated in the 'usa' configuration on this screenshot, if 'uk' - params from the corresponding row will be taken, if there are no matches - email won't be changed.

Multi-Product-Settings-Mautic-Page

Also, you can prioritize the settings - upper config strings have priority over the lower ones. In this example, if the contact has an "usa.mysuperservice.com" 'domain', the email will be sent from [email protected] through Sendgrid. If the next customer has a "pt.mysuperservice.com" or any other domain with "mysuperservice.com", except 'usa' and 'uk' - the email will be sent from [email protected] through Sparkpost.

Please note:

  • Multi-Product Settings always have priority over the API Keys settings. So when sending email, it checks the Multi-Product Settings first, if nothing found - Custom API settings. If there are no matches in both configurations - email will be sent through the default email service indicated in the main settings.
  • You can use any custom field - just change the 'product_field_name' parameter in the plugin's config file. Make sure this field exists in your Contact (Lead) custom fields.

Author(s)

Enjoy!

About

This feature allows Mautic to send different emails through different mail API keys.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages