Toggle menu

Email

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).

PropertyTypeDescription
SMTPServerString, optionalOverride the default SMTP server. Uses iCM's mailserver if not set
SMTPPortInteger, optionalOverride the default SMTP server port
SMTPAuthBoolean, optionalEnable SMPT authorisation, default false
SMTPtls_sslString, optionalEither "TLS", "SSL", or "". Default ""
SMTPUserString, optionalA user name for SMTP authorisation
SMTPPasswordString, optionalA password for SMTP authorisation
bounceToString, optionalA default return-path address for failed email
fromString, optionalOverride the default "from" address. Uses iCM default sender address if not set. This must be a valid address allowed to send from your domain. May also use an address object 
apiWorkerString, optionalOverride the URL used to access the iCMAPI Worker (we don't recommend changing this)
fileWorkerString, optionalOverride the URL used to access the Filestore Worker (we don't recommend changing this)
mediaDirString, optionalOverride the filepath to iCM's media directory (don't change this)
boilerplateObject, optionalHTML emails may include headers and footers. Provide a default and additional "from" address specific markup
pdfboilerplateObject, optionalPDF 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 boilerplate and pdfboilerplate properties can insert custom headers and footers into the HTML emails generated by the worker. The default headers and footers are applied to all emails that do not match one of the defined from addresses. Supplied styles will be inlined into the final HTML in an attempt to work consistently across email clients. Headers and footers are not added to emails sent as plain text.

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>"    
    }
}

API

sendmail

Sends one or more emails using the supplied parameters.

Share this page

Facebook icon Twitter icon email icon

Print

print icon