BoltWire

Pro Modules

Mailer

The mailer script is a powerful piece of software that allows you to send all sorts of email in all sorts of ways. You can use it to generate autoresponders, run small newsletters, send out a drip sequence, run a class, and more.

To use it, make sure you have mailer enabled in your site.config page. Second, make sure you have email capabilities confirmed by using the tester feature at site.email.

This script is hard-coded to max out at under 100 emails per hour, to stay within sending limits at directnic, which is the email service I recommend using for the accelerator program. That number could be changed if you are using another service like mailgun or the like.

Preparing Mail

There are two parts to the mailer plugin. Scripts to queue up messages according to your prearranged instructions. And a function to send those messages at the appropriate time. Let's talk about getting your mail ready to go first.

Basically, you have four modes in the mailer command: note, drip, news, and push. Here's how each of them work:

note: Send an individual email to an individual member. It requires the following parameters:

subject
body
id

drip: Send a series of emails to an individual at a schedule you specify. It requires the following parameters:

drip
id

news: Send a single email to a group of members. It requires the following parameters:

subject
body
group

push: Start a group of members on a sequence of emails. It requires the following parameters:

drip
group

In all of the above commands, you can include a start parameter to indicate when the message (or first message) is sent. The body parameter can be the actual content, or a saved code.message.body page. If it is a drip or push command, you can set a count parameter to indicate which message to start at. The group parameter can be fixed or dynamic, and in the case of the push command will be recalculated at the start of each new message in the series. Last, each requires a mode=active parameter to actually send mail. Otherwise a demo mode is used for testing.

Here's an example of a simple form you could send someone a message:

[form]
[submit JOIN]
[command mailer note to={id} subject='Welcome to my site' body=welcome]
[command nextpage members.thanks]
[form]


Basically it takes the content in code.message.welcome and sends it to the person who clicks the JOIN button, after which they are forwarded to a thank you page. Normally this line would be added to another form that subscribes them to a newsletter, adds them to a class, or unlocks some content.

And last but not least there is a mailer cancel command which takes an id and drip parameter. This can be used to find the appropriate mail page and delete it. This is used for example, if someone cancels a class before completing the email sequence.

Explore the site.mailer area to see how the various forms are constructed. You can easily build your own or attach emailing to user generated actions.

The Cron Mailer

Outgoing messages are stored in pages like mail.1454534565.note.id or mail.1545654534.drip.series.group. While these are system files used by BoltWire, they can be edited like any other file. Meaning you can edit the content of outgoing mail, change the recipient list, reschedule messages (the 10 digit string of numbers is a timestamp), or cancel a queue completely--by simply deleting the file.

The site.mailer section of your accelerator site contains a page that allows you to see all pending mail messages. Note that these page names change dynamically as they are being processed, so if you are going to change something you have to do it fast. My advice: change the name quickly to something like mail2 instead of mail--to take it out of the mail queue. Then once you have changed it how you want, change it back to mail to put it back in.

Sending Mail

Sending mail requires is done by a special cronmailer function which scans all your queued mail, determines what needs to be sent, and starts sending mail. It then tracks each outgoing email, to ensure you stay within your allowed sending limits.

By default, it's limited to under 100/hour, though with a larger transactional email service like mailgun, you could increase that number--and potential use this plugin for all your outgoing mail. Generally, for large mail lists however, I recommend using the subscriber plugin and sending messages through MailerLite, which can send thousands of messages effortlessly without slowing down performance on your site. Use this plugin for basic transactional mail, short drip sequences, and for messages to small groups.

For the mail to be sent, the cronmailer function must be triggered. This can be done by a cron job if you have server access, or by a ping service which "pings" your site every few minutes. This has the added advantage of monitoring your site uptime, and sending periodic reports and alerts to show when your site is down.

The service I recommend is freshping. It is a free service, and will ping your site every 2 minutes I believe. Just point it to www.mydomain.com/cron and everything should work automatically. It's a set it and forget kind of thing.

The cron master at page cron is designed to forward incoming pings to the appropriate cron job, like cron.mailer which actually runs your mail program. That cron job stores a log at cron.mailer.log so you can see what it happening. Try queueing up a message to yourself and then see if it comes through.

Note that messages can take a couple minutes to come through because it has to first wait for a ping, and then second, wait for its turn in the queue. If it's part of a newsletter, it can take several hours to go through, as only five ids are sent at each ping, and only up to a combined sending limit of under 100. Mail not sent at the scheduled time will be sent at the earliest possible time.

Drip Messages

While the note and news modes send a single message (to an individual or a group), the drip and push modes send a series of messages. Single messages can be user generated or drawn from a code.message.name file. But drip files come from a series of special code.drip pages. Here's how they work:

First, you need a page that provides a schedule for your drip. Let's say you had a simple four lesson course on basic Basic Weaving, and you mailed out an email once each day. To create a drip for this class, you could simply create a page called code.drip.baskets, with contents that look something like this:

1: 0 | Welcome to the Class
2: .01 | Day 1. Introduction to Basket Weaving
3: 1 | Day 2. Basic Weaving Techniques
4: 1 | Day 3. Principles of Basket Design
5: 1 | Day 4. Put it all together...

The numbers (1-5) are the "keys" for the actual emails you will send. The first part of the info var represents how long (in days) you wait to send the next message. The second part of the info var is the subject line that will be assigned to the email.

In this case, the welcome email is sent immediately (0), the Day 1 lesson is sent about 15 minutes later (Each .01 works out to 14.4 minutes). And Day 2-4 come a day later each. If I wanted to include an extra email between day 2 and 3 for example, for a supplemental checkin email to see how they are doing, and maybe send a follow-up email a couple days later, I could change the scheduler to look like this:

1: 0 | Welcome to the Class
2: .01 | Day 1. Introduction to Basket Weaving
3: 1 | Day 2. Basic Weaving Techniques
4. .6 | How is it going?
5: .4 | Day 3. Principles of Basket Design
6: 1 | Day 4. Put it all together...
7: 3 | Ready for another class?

Here, the "How is it going?" email is sent .6 days after the day 2 email (which amounts to about 14.5 hours) and then Day 3 resumes at the right time, a full day after Day 2 (.6 + .4 = 1). Then there's a follow up email "Ready for another class?" that comes out 3 days after they get the Day 4 email.

Obviously you could change this schedule to accommodate any email sequence you want--including weekly classes, or a 30 day follow-up email.

I could also have a drip called code.drip.basket-grads that contains a separate follow up series for graduates, maybe designed to encourage them to sign up for Basket Weaving II. :)

The actual content of the message is stored at code.drip.basket.1, code.drip basket.2 etc. You can edit these messages at any time and those changes will automatically be applied to all queued mail, as the mailer plugin generates the content for each message at the time it is set to go out.

Note that if you insert steps into your scheduler, you will need to rename your drip files so the right emails gets sent out at the right time.

Both subject lines and message bodies can be customized with mbase values by simply inserting the normal mbase code. IE, if you want to insert their name in the subject line, put {~name}.

The site.mailer section has several tools to help you track various logs, to make sure your messages are going out, and help you troubleshoot issues if they are not. Available email message files and email drip files are listed in the site.email section.