Overview
The Email Worker has a single method, sendmail, which will take various parameters to construct and send one or more emails. In its simplest form sendmail will accept just three parameters ("to", "subject" and "body") and retrieve the remaining details from the worker configuration.
Beyond this the worker offers significant scope for customisation, including custom headers and footers, using Handlebars to produce templates for both the subject and body of the email, and embedding Google Analytics tracking and campaign tags. Lists of recipients and any associated data can be supplied from mailing rules and iCM user profiles, or as text files containing data in either a JSON or CSV format.
Limits
All mail servers put limits on the total size of the emails they will accept. In AWS (our main hosting provider) the size limit is 40MB after encoding for the complete email, including embedded images and attachments.
There is also a limit of 50 recipients for a single message (combined "to", "cc" and "bcc"). When sending emails you should be emailing each recipient individually. The use cases for recipients having a message with the same message-id are limited to situations in which the recipients are expected to interact with the message as a group, for example, recipients using reply-all to the email and having a resulting email conversation.
Worker Configuration
Many of the default values of the properties listed below are found in the configuration of your API Server (which come, ultimately, from iCM's autoconfig).
Property | Type | Description |
---|---|---|
SMTPServer | String, optional | Override the default SMTP server. Uses iCM's mailserver if not set |
SMTPPort | Integer, optional | Override the default SMTP server port |
SMTPAuth | Boolean, optional | Enable SMPT authorisation, default |
SMTPtls_ssl | String, optional | Either |
SMTPUser | String, optional | A user name for SMTP authorisation |
SMTPPassword | String, optional | A password for SMTP authorisation |
bounceTo | String, optional | A default return-path address for failed email. This must be a verified address, in the same way as the "from" address |
from | String, optional | Override the default "from" address. Uses iCM default sender address if not set. This must be a valid address allowed to send from your domain - see Verifying Sender Email Addresses. May also use an address object |
apiWorker | String, optional | Override the URL used to access the iCMAPI Worker (we don't recommend changing this) |
fileWorker | String, optional | Override the URL used to access the Filestore Worker (we don't recommend changing this) |
mediaDir | String, optional | Override the filepath to iCM's media directory (don't change this) |
boilerplate | Object, optional | HTML emails may include headers and footers. Provide a default and additional "from" address specific markup |
pdfboilerplate | Object, optional | PDF HTML headers and footers. Provide a default and additional "from" address specific markup |
Example
{
"name": "email",
"instances": 1,
"threadsPerInstance": 5,
"SMTPServer": "my.new.server",
"from": {
"address": "support@somewhere.com",
"name": "Bob"
},
"boilerplate": {
"default": {
"header": "<html lang='en'><head><title>Your Form Submission</title><style type='text/css'></style></head><body style='background-color: #FFFFFF;'><center><table width='600' cellpadding='10' cellspacing='10' border='0' bgcolor='#FFFFFF'><tr><td valign='top' style='font-family: Helvetica, sans-serif;'>",
"footer": "</td></tr></table></centre></body></html>"
}
},
"pdfboilerplate": {
"default": {
"header": "<html><head><title>Form Submission</title></head><body class='body'><h1 class='main'>Your Form Submission</h1>",
"footer": "</body></html>"
}
}
}
Using Custom Headers and Footers
The
This Campaign Monitor article on CSS has some helpful advice on email styling. There are also restrictions for the automatically generated PDF attachments, which should stick to using the conventions of CSS 2.1.
The following example shows a boilerplate entry with two members. The default, which sets some colours, and a rule for emails sent "from" goss.demo@gmail.com, which includes styles and content to provide a banner and footer. The pdfboilerplate sets the colours and fonts to use in the PDF.
Note how the HTML used in the header and footer elements uses single rather than double quotes to avoid issues of escaping when included in the JSON message.
"boilerplate": {
"default": {
"header": "<html><head><style>body{background-color:#2a2a2c; color:#f3a7d4;}</style></head><body>",
"footer": "</body></html>"
},
"goss.demo@gmail.com": {
"header" : "<html lang='en'><head><title>Your Form Submission</title><style type='text/css'></style></head><body style='background-color: #FFFFFF;'><center><img src='https://knowledgebase.gossinteractive.com/image/3687/emailheader/original.PNG' alt='Link to homepage'><table width='600' cellpadding='10' cellspacing='10' border='0' bgcolor='#FFFFFF'><tr><td valign='top' style='font-family: Helvetica, sans-serif;'>",
"footer" : "</td></tr></table><img src='https://knowledgebase.gossinteractive.com/image/3688/emailfooter/original.PNG' alt='Link to homepage'></centre></body></html>"
}
},
"pdfboilerplate": {
"default": {
"header": "<html><head><style>body{background-color:#fff; color:RebeccaPurple;} h1{font-family: 'Palatino Linotype','Book Antiqua',Palatino,serif; font-size: 18pt;}</style></head><body>",
"footer": "</body></html>"
}
}