Skip to main content

Using Any Email Delivery Service for Email Sending from Kuroco(Mailchimp)

Overview

By using the trigger "Replace the default email sending method (SendGrid)", you can send notification and invitation emails using any email delivery service such as blastengine, Mailchimp, Amazon SES, etc.

This tutorial will guide you through the steps to replace email sending from SendGrid to Mailchimp.

What you'll learn

You will learn how to implement email sending using any email delivery service with the following steps:

Prerequisites

info

In this tutorial, we will be using Mailchimp's Transactional API for sending emails.
Please refer to Mailchimp and its API documentation for more details about the service.

Also, since we will be configuring SPF/DKIM, make sure to use a domain that you own for the "from" email.

caution

Please note that if you do not use SendGrid, you will not be able to use the tracking features (delivery, email bounce, open rate, click count).

Setting up Mailchimp

Account registration

First, access Mailchimp and register for an account.

Image from Gyazo

Obtaining the API key

Once the activation is complete and you have logged into your account, click on [Automations] -> [Transactional email] and then click [Launch App] to access the dashboard.

Image from Gyazo

Click on [Settings].

Image from Gyazo

Click on [Add API key].

Image from Gyazo

Make a note of the API key that is displayed.

Adding a sending domain

Next, you need to add the domain that will be used as the sender of the emails and configure authentication, SPF, and DKIM.

Click on the [Domains] tab and enter the domain that will be used as the sender, then click [Add].

Image from Gyazo

The added domain and the necessary settings for using the domain will be displayed. Click on [View details], [View DKIM settings], and [View SPF settings] to configure the required DNS settings.

Image from Gyazo

Verified Domain

To authenticate the domain, set the value specified in the TXT record of the domain.

Image from Gyazo

DKIM Settings

Set the value specified in the TXT record of specified selector._domainkey.domain name for DKIM.

Image from Gyazo

caution

If the length of the VALUE exceeds the maximum allowed characters, you need to split the TXT record and register it separately.
If necessary, please contact your domain management service for assistance.

SPF Settings

Set the value specified in the TXT record of the domain for SPF.

Image from Gyazo

Once you have configured each setting, it should look like the following:
※ The screenshot is an example for the case of using "お名前ドットコム" as the domain.

Image from Gyazo

Click on [Test DNS Settings] to confirm all authentication and complete the setup.

Image from Gyazo

caution

With MailChimp's Free plan, you can only send and receive emails to and Sending Domains that have been registered and have completed all authentication. If you want to allow sending to all email addresses, please subscribe to a paid plan.

Setting up Kuroco

Register the Secret

Access the Kuroco management screen and In the left sidebar menu, under "SETTINGS", click [Environment] -> [Secrets].

Image from Gyazo

Click on [Add].

Image from Gyazo

Register the API key obtained from the Mailchimp dashboard.

FieldValue
NameMAILCHIMP_API_KEY
ValueAPI key from Mailchimp

Image from Gyazo

With this, the preparation for using Mailchimp is complete.

Register Custom Processing

Once you have prepared to use Mailchimp, write custom processing to replace email sending with SendGrid to Mailchimp.

In the left sidebar menu, click [Operation] -> [Custom function]

Image from Gyazo

Click on "Add".

Image from Gyazo

Configure as follows: |Field|Value| |:--|:--| |Title|sending_email_with_mailchimp| |Identifier|sending_email_with_mailchimp| |Trigger|Replace the default email sending method (SendGrid)| |Processing|The following content|

sending_email_with_mailchimp
{* Set Request Headers *}
{append var=headers value="Content-Type: application/json"}

{* Set Body *}
{assign var='payload' value=$payload|@json_decode}
{assign_array var='body' values=""}
{secret var='body.key' key='MAILCHIMP_API_KEY'}
{assign var='body.message.from_email' value="noreply@kuroco-mail.app"}
{assign var='body.message.subject' value=$payload.subject}
{assign var='body.message.text' value=$payload.text_part}
{assign_array var='to' values=""}
{assign var='to.email' value=$payload.to}
{assign var='to.type' value="to"}
{append var='body.message.to' value=$to}

{* Send Request *}
{api
endpoint="https://mandrillapp.com/api/1.0/messages/send"
method='POST'
headers=$headers
body=$body
var=response
status_var=status
}

{logger msg1="mailchimp_mail_log" msg2=$body msg3=$response}
{assign var="is_mail_sent" value=true}
caution

Replace noreply@kuroco-mail.app with your own email address.

Image from Gyazo

Once you have entered the information, click on [Add] to add the custom processing.

Confirmation of operation

Let's send an email from Kuroco to confirm the operation.
For the purpose of confirmation, we will use the password reminder.

Access the Kuroco login screen and click on [Forgot your password?].

Image from Gyazo

Enter your email address and click on [Send].

Image from Gyazo

caution

If you are using the Free plan, the recipient's email address must be authenticated with the Mailchimp sending domains.

When you check Activity in Mailchimp, you can see that the email was sent from Mailchimp.

Image from Gyazo

With this, the configuration to use any email delivery service is complete.


Support

If you have any other questions, please contact us or check out Our Slack Community.