Skip to main content

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


By using the trigger "Instead of 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.

In this tutorial, we will show you how to replace email sending from SendGrid to blastengine.

What you'll learn

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



In this tutorial, we will be using blastengine for email sending. .
Please refer to the blastengine website for detailed information about the service, as well as its API documentation.

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

Setting up blastengine

First, access blastengine and sign up for a free trial.

Image from Gyazo

Once you have logged in to your trial account, click on "Address Registration" under the "API Integration Trial" tab to enter the address that will allow delivery from blastengine.

Image from Gyazo

Next, obtain the API key.
Click on the "Settings" page to go to the blastengine settings page.

Image from Gyazo

Click on "Check/Reissue" for the API key.

Image from Gyazo

Take note of the API key that is displayed.

Image from Gyazo

Also, access the Account Management page and take note of the ID.

Image from Gyazo

Setting up Kuroco

Registering 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 blastengine settings page and the ID as shown below.

ValueAPI key of blastengine
ValueID of blastengine

Image from Gyazo

You have now completed the preparation to use blastengine.

Registering custom processing

Once you have prepared to use blastengine, write the custom processing to replace email sending from SendGrid to blastengine.

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

Image from Gyazo

Click on "Add".

Image from Gyazo

Configure as follows:

TriggerInstead of the default email sending method (SendGrid)
ProcessingThe following content
{* Create BearerToken *}
{secret var='apiKey' key='BLASTENGINE_API_KEY'}
{secret var='id' key='BLASTENGINE_ID'}
{rcms_hash var='token' data="`$id``$apiKey`" algo="sha256"}
{assign var='BearerToken' value=$token|strtolower|base64_encode}

{* Set Request Headers *}
{append var=headers value="Authorization: Bearer `$BearerToken`"}
{append var=headers value="Content-Type: application/json"}
{append var=headers value="Accept-Language: ja-JP"}

{* Set Body *}
{assign var='body' value=$payload|@json_decode}
{assign var='' value=""}

{* Send Request *}

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

Please change to your own email address.

Image from Gyazo

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

Confirmation of operation

Let's actually send an email from Kuroco. To confirm the operation, we will use the password reminder.

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

Image from Gyazo

Enter the email address that has been allowed to receive emails from blastengine and click [Send].

Image from Gyazo

When you check the received email, you can see that the "from" address is the email address in the custom process and the display of "via".

Image from Gyazo

Also, when you check the delivery log of blastengine, you can see that the email was sent from blastengine.

Image from Gyazo

Increasing email deliverability

So far, you have been able to send emails using blastengine. To prevent sent emails from being classified as spam, we will set up SPF records and DKIM authentication.

By implementing email authentication, you can prevent email spoofing and verify that the email was actually sent by the domain owner.

As the processing for emails without SPF/DKIM settings becomes stricter year by year, be sure to implement these settings.

Setting up SPF records

Set the following TXT record in the domain management service.

BlankTXTv=spf1 ~all

After setting it up, use MxToolbox's SPF Record Check to verify that it is set up correctly.

Image from Gyazo

Setting up DKIM

Next, set up DKIM. First, prepare a pair of public and private keys, and set the private key in blastengine.

Generating private and public keys

Generate the private key using the OpenSSL command-line tool in your local environment. First, open the terminal and check if OpenSSL is available using the following command.

openssl version

If OpenSSL is not installed, please install it separately, especially for Windows.

Next, create a private key with the following command.

openssl genpkey -algorithm RSA -out private_key.pem

The public key can be extracted from the private key using OpenSSL.
Here is the command to do so.

openssl rsa -pubout -in private_key.pem -out public_key.pem

Register with blastengine

Register the created private key with blastengine.

Access the blastengine settings page and click on [Confirm/Change] for DKIM Signer Settings.

Image from Gyazo

The DKIM Signer Settings will be displayed. Click on "New Registration" and set the following:

DomainThe domain used in the "From" email
Private KeyThe private key starting with -----BEGIN PRIVATE KEY----- that was created earlier

Image from Gyazo

Once the input is complete, click [Confirm] to register.

Configure DNS

Set the following TXT record in the domain management service:

kuroco._domainkeyTXTv=DKIM1; k=rsa; p=The part of the public key without the -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY-----

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

Once the configuration is complete, use MxToolbox's DKIM Record Lookup to verify that it is set correctly.

Image from Gyazo

Send another email from Kuroco to confirm that the "From" address is now the custom processing email address, and there is no longer a "via" indication.

Image from Gyazo

With this, the configuration for using any email delivery service is complete.


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