Technical Services
Non Insurance Services
SNS Components
Email Service
Sidebar On this page

Introduction

Our email service is a connector to SMTP-based email server and SendGrid email service. It supports sending out emails with a plain text body or attachment in a business scenario like policy issuance. The manual and restful APIs are provided for user.

Usage Scenarios

Email service is designed to help digital marketers and application developers send marketing, notifications, and business emails. It is a reliable, economical, and practical service for enterprises of all sizes that contact customers with email. The user can configure their own email account before using the service.

Apply for an email sender

If you need to apply for an email sender of your own domain with aws ses, the following table shows the information you need to fill in.

TitleExampleDescription
Project Code1234567 XXX project
Email Sender Address / @Domainxxx@insuremo.com / @your-domain.comThe email address you want to send from
Site / EnvptdevThe site or environment that the email will send from
Type of emailSend to policy holder after issuingBriefly describe the type of email your will send
Quotas100 emails per dayExpect number of emails sent per day
Other requirementsNoneSuch as configuration set rules, DKIM, SPF, specify the region…
note

If you need to add configurations such as DKIM or SPF to prevent being identified as spam by the recipient, please verify your domain.

Basic UI Operations

Entrance

  1. Log in to insureMO Portal with your personal account.
tip

If you don’t have insureMO personal account, click Sign Up to register one. Then log in to the portal.

  1. Click Catalog at the top of the home page.

  2. In the left panel of the Catalog page, navigate to Non Insurance Services > Communications.

  3. Find EMail Service card. You will see API Details and Settings.
    email-card
    a. API Details will give you direct access to the APIs listed in it.
    api-details
    b. For creation and other actions, you need to click Setting to go to the Email Management page.
    email-setting
    c. This will navigate to the main email settings page where you can manage the service.
    email-page

Account Management

Create

  • Click Create on the email service console.
account-create_01
  • Register your email account. Click Submit. It will be saved and appear in the list in the main page.
account-create_02

Edit

  • Click Edit on the email service console.
account-edit

Delete

  • Click Delete against a particular record to delete the account.
account-delete
note

After confirming deletion, the account will not continue to be used. Before deleting the account, make sure that the account is no longer used by the application.

Share

  • Click Share to share the current configuration of email account operator with other tenants.
account-share_01 account-share_02

Test

  • After the account is created successfully, you can verify whether the current account is available through a test email. If available, the receiver will receive the following test email.
account-test_01 account-test_02 account-test_03

Blacklist Management

The blacklist stops emails from being sent to specific recipients. It applies to every email the tenant sends, whichever account or sender is used. A platform-wide blacklist maintained by insureMO is also applied on top of the tenant’s own list.

blacklist-page

How It Works

  • Each recipient in to, cc and bcc is checked against the blacklist before sending. Matched recipients are removed silently, and the email is still sent to the remaining recipients.
  • If no recipient is left after the check, the request fails and nothing is sent.
  • Removed recipients are recorded in the email send log.
  • Changes to the blacklist take effect within 1 minute.

Match Types

Match TypeMatchesExample
Whole WordThe whole address exactly. The comparison is case-sensitive.john@example.com
Path MatchA wildcard pattern: * matches any characters, ? matches a single character.*@example.com
RegexA regular expression (RE2 syntax). A match anywhere in the address counts, so use ^ and $ to match the whole address.^.+@(test|demo)\.com$
caution

A regex without ^ and $ matches part of an address. For example, test blocks test@example.com and also contest@example.com.

Create

  • Click Create on the Blacklist management page, select the Match Type, enter the address or pattern, and click Submit.
blacklist-create_01 blacklist-create_02

Delete

  • Click Delete to remove an entry from the blacklist. Entries cannot be edited. To change one, delete it and create it again.
blacklist-delete

Template Management

A template stores the subject and body of an email under a Template Code. When sending, pass template_code and template_params instead of subject and content, and the service fills in the variables.

template-page

Create

  • Click Create on the Template management page, fill in the fields below, and click Submit.
template-create_01 template-create_02
FieldRequiredDescription
Template CodeYesUnique within the tenant. Used as template_code when sending.
Template EngineNoThe syntax for variables. See Template Engines.
Content TypeNotext/html (default), text/plain, or multipart/alternative.
SubjectNoSupports variables. If empty, the subject must be passed when sending.
ContentYesThe email body. Supports variables.
Alternative ContentYes, if the content type is multipart/alternativeThe plain-text version of the body, shown by email clients that do not display HTML.

The template is checked for syntax errors when it is saved.

Template Engines

EngineVariable SyntaxNotes
Handlebars{{ variable }}Handlebars syntax, including {{#if}} and {{#each}}. HTML in values is escaped.
Go Template{{ .variable }}Go template syntax with Sprig functions. In HTML content, values are escaped.
Simple${variable}Plain replacement only. A variable that is not passed stays in the email as ${variable}.

Example with the Simple engine:

Subject: Policy ${policy_no} has been issued
Content: <p>Dear ${name},</p><p>Your policy ${policy_no} is now in force.</p>

Send request:

{
"template_code": "policy_issued",
"template_params": {
"name": "John",
"policy_no": "P20260001"
},
"to": ["john@example.com"]
}
note
  • template_params is not recorded in audit logs, so it can carry personal data. Parameters that should be recorded belong in sender_params.
  • A subject in the send request overrides the template subject.
  • If the send request sets content_type, it must match the template’s content type.

Edit and Delete

  • Click Edit to change a template. The Template Code cannot be changed.
  • Click Delete to remove a template. Requests that still use its code will fail. Make sure no application still uses the template before deleting it.

Import and Export

  • Export downloads templates as a JSON file: all templates, the current page, or the selected rows.
  • Import uploads such a JSON file, for example to copy templates from one environment to another. A template with the same Template Code is overwritten.

Log

• You can view the log files in the Audit Service, they are available for a particular day and can be downloaded as well. This is required for audit purpose and to check if there is any issue in the service.

log-page

Developing with Email Service

Send Email

Calling REST APIs

For all API list, see insureMO API Reference - email.

After the mail account is configured by the tenant, the tenant can call the API to send emails.

note

Restriction Description

  • We will monitor the content of emails sent by users to prevent it from violating the requirements of national laws and regulations.

  • If the message content violates the rules, the relevant users will be frozen. After the account is frozen, the user cannot continue to use the mail service.

Authentication

HTTP Authentication, scheme: bearer

POST SendEmail

API URLMethod
https://[HOST]/mo-fo/1.0/sns/email/sendPOST
  • Header
ParameterValue
AuthorizationBearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Body Parameters

{
"account_name": "insuremo@insuremo.com",
"alias": "insureMO",
"attachments": [
{
"content": "string",
"content_id": "string",
"headers": {
"property1": "string",
"property2": "string"
},
"mime_type": "string"
}
],
"auto_format_html": false,
"bcc": [
"sample@insuremo.com"
],
"cc": [
"sample@insuremo.com"
],
"content": "string",
"content_type": "text/html",
"custom_headers": {
"property1": "string",
"property2": "string"
},
"priority": false,
"reply_to": "string",
"sender_params": {
"property1": "string",
"property2": "string"
},
"subject": "Email Service Testing Email",
"template_code": "string",
"template_params": {
"property1": "string",
"property2": "string"
},
"to": [
"sample@insuremo.com"
]
}

Response Examples

If the code is “i_common_success”, it indicates successful sending. Otherwise, the sending fails.

{
"code": "i_common_success",
"data": {
"content_length": 0,
"data": "string",
"message_id": "string"
},
"message": "string",
"message_params": [
"string"
],
"trace_id": "string"
}

Using insureMO Email SDK For Java

Please refer to this document: Welcome to insureMO SDK for Java.

Code example:

import com.insuremo.sdk.core.exception.ApiException;
import com.insuremo.sdk.services.sns.SnsSdkClient;
import com.insuremo.sdk.services.sns.api.EmailApi;
import com.insuremo.sdk.services.sns.bundle.SendEmailResponseBundle;
import com.insuremo.sdk.services.sns.model.SendEmailRequest;

public class EmailApi_sendEmail {

public static void main(SnsSdkClient snsSdkClient) {
System.out.println("----- Example for EmailApi.sendEmail -----");
EmailApi emailApi = snsSdkClient.emailApi();

System.out.println("----- sendEmail -----");

try {
SendEmailResponseBundle responseBundle = emailApi.newSendEmailRequestBuilder()
.sendEmailRequest(new SendEmailRequest().
accountName("portal-test@insuremo.com").
subject("email testing").
content("This is a testing email").
addToItem("sdk-test@simulator.insuremo.com"))
.doRequest();
System.out.println(responseBundle.getBody().getData());
} catch (ApiException e) {
System.out.println(e.getResponseBody());
System.out.println(e.getCode());
}
System.out.println("----- Done. -----");
}
}

Send 2FA Email (Verify Code)

Please see Send An MFA Code via Email.

Migrate to SNS API

Send Email

API:

https://[host]/eBao/1.0/email/send

=>

https://[host]/mo-fo/1.0/sns/email/send

Request Body:
/eBao/1.0/email/send/mo-fo/1.0/sns/email/sendData TypeDifference
accountaccount_namestring
aliasaliasstring
attachmentattachmentsarray/Object
attachment.attachmentContentattachments.contentstring/byte
attachment.attachmentMimeTypeattachments.mime_typestring
attachment.attachmentNameattachments.content_idstring
autoformat-boolDeperated field. You should specify email content type as html(default) or text and format the content.
bccbccarray/string
ccccarray/string
consigneetoarray/string
contentcontentstring
contentTypecontent_typestring
contentFilesattachmentsarray/ObjectSame as attachment
contentFiles.attachmentContentattachments.contentstring/byte
contentFiles.attachmentMimeTypeattachments.mime_typestring
contentFiles.contentIdattachments.content_idstring
contentFiles.headersattachments.headersmap/string
customHeaderscustom_headersmap/string
priorityprioritybool
replytoreply_tostring
subjectsubjectstring
templateCodetemplate_codestring
templateParamstemplate_params
sender_params
map/stringSplit into two different parameters.
template_params is used for value replacement in templates and will not be recorded in audit logs.
sender_params specifies the parameters for sending the email and will be recorded in audit logs.
Response:

/eBao/1.0/email/send

Success Response:

HTTP Status Code: 200

{
"body": "abcd1234-ab12-cd34-ac13-abcd1234abcd",
"info": "abcd1234-ab12-cd34-ac13-abcd1234abcd",
"status": 0
}

Failed Response:

HTTP Status Code: 200

{
"body": null,
"info": "error message",
"message": "error message",
"status": 1
}

=>

/mo-fo/1.0/sns/email/send

Success Response:

HTTP Status Code: 200

{
"code": "i_common_success",
"data": {
"content_length": 0,
"data": "string",
"message_id": "string"
},
"trace_id": "string"
}

Failed Response:

HTTP Status Code: 499 / 599

{
"code": "e_sns_email_error_code",
"message": "string",
"message_params": [
"string"
],
"trace_id": "string"
}

FAQs

Q: What email can I send?

A: Triggered email: Emails triggered by events, such as registration notification, transaction notification, and verification notification emails.

Batch email: Subscription emails sent to members, such as product promotion, user notification, periodical information. The email service only allows sending commercial emails permitted by the recipient. The mail content is the recipient’s active subscription. The unlicensed spam is not allowed to be sent.

Q: Can the attachments be added to email?

A: Yes, see API interface for more details.

Q: Why did all the emails go into the recipient’s junk mailbox?

A: It’s generally because the email content is judged as spam by the recipient’s system. Attempts can be made to adjust the email content and avoid the use of spam terms. Then send a test email to your other mailboxes to check if the new content is still considered as spam.

Q: Suggestions on Spam Handling

A: Standardize the email content and use the link address of website. Avoid using short link address. Otherwise, it will be regarded as spam.

Add the address of the unsubscribe link to the email content and perform the actual unsubscribe. At the same time, remind the recipient to add the sender’s address to the whitelist or to contact at a clear location. At the same time, add the introduction of your company and products.

If the sender sends the same message to multiple recipients at the same time, it may also be automatically identified as spam by the system.


Feedback
Was this page helpful?
|
Provide feedback