Sending Mail with Drafts
Drafts is a great place to, well, draft emails. Using Drafts allows you to use a convenient, configurable editor for a consistent writing experience and it’s easy to send email directly within the app - or by integrating with third party Mail clients. Even write in Markdown and send as rich HTML email. This article covers some of these basics of using email in Drafts.
Mail Action Step
Drafts ships with a default Mail action, in the “Basic” action group. This action is configured to send plain text mail with the built-in iOS Mail app, using the first line of the current draft as the subject and the remaining text as the body of the email. When used, a Mail window will pop up with the text already filled in. You add a recipient and tap “Send” and your mail is on the way.
This is only the beginning of what is possible with the Mail action step. Multiple actions can be setup using Mail action steps, each configured to have pre-defined To, CC & BCC recipients, stock subject lines or body templates which automatically add signatures or other reused content and formatting. So it’s easy to setup, for example, a group email action to send to your project team or family.
Because this step uses Mail.app, it can send from any addresses you have configured for use in Mail (selectable in popup mail window), can work offline (message will remain in outbox and send when connected), and sent message will be stored in your “Sent” folder just as if you sent them from within the iOS Mail app.
Configuring Mail Action Steps
If you are new to actions, you can get familiar with the basics of editing actions in our Create an Action screencast, that’s a little beyond this article, but below shows a sample configuration of a Mail action step.
There are more detailed explanations of the fields in the Mail action step documentation. Each of these fields support Drafts template tags, including the recipient fields, so it is possible to dynamically insert content.
The basics are:
- Recipient fields (To, CC, BCC): These fields can each have one or more email addresses (separated by commas). If values are configured for these fields, they will be pre-filled in the Mail window that opens, leaving you only to tap “Send” to finish the email. Use the (+) button to select email addresses from your contact list.
Subject/Body fields: These templates control what text will be filled in the content fields of the mail message. The default values use tags which insert the first line (
[[title]]) in the subject, and the remaining text (
[[body]]) in the body of the message. The figure above demonstrates how these tags can be combined with static text. With the subject template
Band Update: [[title]]the subject line will come out in the mail as
Band Update: First Line of Draft. More about using Templates.
- Send as HTML: If on, this will treat the output of the template as HTML and create a rich-text email. This means that the template should have HTML tags in it. This is typically used along with Markdown, see section below for details.
- Send in background: Used to send the email via web service without the requirement of opening a preview of the message. Because these message come “From” a generic address, it’s best for action which email to your own email address as a reminder, or similar.
Markdown is a text-to-HTML conversion tool that lets you write in simple plain text markup and easily covert it to HTML. Drafts has great Markdown support, and it works nicely with Mail steps to create rich-text formatted emails.
To get started, install the Markdown Mail sample action from the Action Directory. This action uses a standard Mail action step, with two configuration changes:
- The “Send as HTML” option is enabled.
- The body template is changed to
%%[[body]]%%. The double-percent syntax is a feature of the [Drafts template engine] that tells Drafts to treat any text between the double-percents as Markdown, and convert it to HTML.
Using this step, it makes it quick and easy to send professional, rich-text email without a lot of fiddling with text selections in Mail.app.
Gmail and Outlook Action Steps
In addition to the “Mail” action step, there are dedicated steps available to send background email via Gmail or Microsoft Outlook.com/Live/O365 accounts. These steps are configured very similar to the Mail step as covered above, but they do not open a window before sending the email. As a result these action steps must include at least one valid recipient email to send properly.
The primary advantage of these steps is to allow a background email (without additional “Send” popup step) to be sent “From” your actual address with one of these services.
Third Party Email Apps
In addition to direct Mail support, Drafts can work with many third party email clients. There are two common ways to send email using third party iOS email clients: Share extensions and URL schemes.
Many email client apps provide share extensions that can accept text and can be used via the Drafts Share action. When provided, these extensions will generally allow you to send an email, and use the text as the body of the email - requiring you to fill in the recipients and subject - just as the built-in iOS Mail share option.
Many popular email client apps also provide support for integration via custom URL schemes. The format of the required URLs and the features they support varies between clients, but most allow sending subject and body text. Some example actions are available in our Action Directory for most popular third party clients, like:
This introduction doesn’t go deep enough to talk about scripting, but be aware that feature described above can also be accessed via the Mail script object in script steps - open all sorts of advanced possibilities. Scripting interfaces are also available to send via Gmail and Outlook accounts directly - allowing use cases like looping over a list of email addresses and sending the same email individually to each as a “To:” recipient.
Can I send in the background using my own Mail accounts?
- Yes, if you use Gmail or Outlook integrated accounts. If a mail step uses the “Send in Background” option, it is sent using a web service. Mail.app does not support background sending.
Can I pre-configure the “from” address in the Mail window if I have multiple accounts?
- No, sadly. This is not an option provided by Apple in the APIs that work with Mail.app. It can be changed in the window that pops up by tapping on the from line.
Other Sample Actions
A search for “Mail” in the Action Directory will always turn up some other interesting ideas for customizing mail actions - a few choice examples: