Overview

Mandrill for Lasso

This is a wrapper for the Mandrill API (http://www.mandrill.com) for Lasso. In addition to the API, it includes a custom version of Lasso's built-in [email_send] tag which bypasses Lasso's email queue and sends messages directly via Mandrill. You can specify default options for tracking opens and clicks, inlining CSS, etc. The tag will optionally fall back to the real [email_send] and use the email queue if the call to Mandrill fails.

Replacement [Email_Send] Usage

Customize mandrill_config.lasso with your Mandrill API key and whatever default Mandrill options you want to use. Place all files in LassoStartup and restart Lasso.

The replacement [Email_Send] tag supports every parameter for which there is a direct correlation in the Mandrill API. Unsupported params are simply ignored. The following table shows how the two match up:

[Email_Send] Parameter Mandrill API Argument
-host n/a
-from from_email, from_name*
-subject subject
-to to*
-body text
-cc (combined with) to*
-extramimeheaders headers
-attachments attachments
-username n/a
-password n/a
-priority not supported, could be set in headers
-replyto headers*
-html html
-contenttype not supported, could be set in headers
-characterset not supported, could be set in headers
-transferencoding not supported, could be set in headers
-contentdisposition not supported, could be set in headers
-sender not supported, could be set in headers
-simpleform not supported
-headertype not supported
-htmlimages images
-immediate n/a
-date not supported

* a custom tag, [mandrill_parseemails], converts a comma-separated list of addresses into the format needed for the API.

Mandrill API Usage

Create a new Mandrill object to work with:

var('m') = mandrill( -key='your_api_key');

Use any method specified in the API reference as a member tag, substituting underscores for slashes in method endpoints. For example, to call /Messages/Send:

$m->messages_send();

Specify top-level method arguments as normal keywords/tag parameters, with a hyphen, e.g.:

$m->messages_send( -async=true);

Within a parameter, use native Lasso arrays for arrays and native Lasso maps for "structs":

$m->messages_send(
    -message=map(
        'html' = '<h1>This is a test!</h1>',
        'text' = '**This is a test!**',
        'subject' = 'Sending directly via Mandrill API.',
        'from_email' = 'joe@schmoe.com',
        'from_name' = 'Joe Schmoe',
        'to' = array(
            map(
                'name' = 'Joe Schmoe',
                'email' = 'joe@schmoe.com'
            )
        ),
        'headers' = map(
            'X-NOT-REAL' = 'some value'
        ),
        'track_opens' = true,
        'track_clicks' = true,
        'bcc_address' = 'joe@schmoe.com'
    )
);

Written and tested against Lasso Professional 8.6.0.1.