Using Mail with Drafts

A Note About Receiving Mail

This article covers sending email from Drafts. It is also possible to send email to your Drafts. For details, see the Mail Drop documentation.

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 with Markdown and send as rich HTML email. This article covers some of these basics of using email in Drafts and different methods available.

Mail Action Step

Drafts ships with a default Mail action, in the “Basic” action group. This action is configured to use the first line of the draft as the subject line, and the remaining text as the body of the message. When used, a Mail mesage will pop up with the text already filled in. You add a recipient and tap “Send” and your mail is on the way.

On iOS, it will use APIs to send via Apple’s Mail app. On the Mac, it uses mailto: URLs to open a message in your default email client.

This is only the beginning of what is possible with the Mail action step. Multiple actions can be set up 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 set up, for example, a group email action to send to your project team or family.

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.
  • Advanced Options:
    • 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 Mail

Markdown is a text-to-HTML conversion tool that lets you write in simple plain text markup and easily convert 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.

Because this relies on APIs that are not available on macOS, the basic implementation of Markdown Mail is not compatible with the Mac. We do offer a free helper app that enables this functionality on the Mac, called Mail Assistant. If you are interested in sending Markdown mail on the Mac, get more information and sample actions in our Mail Assistant article.

Mailto: URLs

With the introduction of iOS 14, it is now possible to have third party email clients configured as your default application to handle mailto URLs. Because of this change, it might be desirable to have mail actions which explicitly use the mailto URL structure to send on both iOS and Mac.

We have posted an example mailto-based action.

The biggest downside to this approach is that you must leave Drafts to complete the sending process.

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 directly. 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:

Scripting Mail

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.

Common Questions

  • 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:

3 Likes

Hi @agiletortoise, need help with an issue. Due to migrating gmail accounts, I had to revoke the OAuth permission that allowed me to send emails in the background and am getting an “oautherror error -11” message.

Could you please tell me How can I reauthirize with a new gmail account?
Thanks !

You need to forget the credentials for the service in settings. Details.

1 Like

As far as I can tell this feature still only works on iOS. Will this be available on the desktop version anytime soon? It’s particularly frustrating as it’s been a long coming - esp as we’re subscribers to the app. And the desktop version shows it as a “supported action”.

1 Like

Most of what is discussed in this article works on Mac. What are you specifically needing or is not working for you?

The only exception to working out of the box on the Mac is Markdown formatted mail, which requires the installation and setup of the Mail Assistant helper app, as discussed above.

Hello guys,
Is it possible to configure the action with protonmail?

If yes, can you point me out?

Thank you
Fabio

Hi there! I’m fairly new to Drafts.

I’m trying to configure it so that I can send email directly from Drafts, thus bypassing the need to check my email inbox. I’ve successfully configured this on my iPhone.

On my Mac, my default mail client is Airmail. However, I’d like Drafts to send email with the Mail app so I can stay within Drafts. The mailto: action seems to be using whatever is the default app. Is there a way to set up the action to use Mail, even if it’s not the default?

Thank you!

Best wishes,

Mel

If you are sending mail using the Mail app, does that not mean that you are explicitly l not staying within Drafts?

Have you looked at the Mail Assistant for Drafts referenced above? There is a from parameter for sending that relies on the Mail app account configuration. I suspect this is what you want to be using.

If you are sending mail using the Mail app, does that not mean that you are explicitly l not staying within Drafts?

That’s not my understanding. In the iPhone app, for example, the Drafts action needs to use a mail client in order to pull up a list of emails, for example, but by using the native Maill app, it can do so with the app in the background and just show you the email your sending. If I use a 3rd party app, it pulls the app into the foreground and I see my stupid email inbox.

I’ll take a look at the Mail Assistant - without further info, it didn’t look to me like it would address the issue I have here since the “mailto:” function seems to be calling whatever is selected as the default app for emailing but I’ll take a look.

Mac does not have the same APIs available to send mail that iOS has…the Mail Assistant is a way to work around that problem. You have to use modified Mail actions that use the Mail Assistant, which is described in the Mail Assistant docs.

Thanks for your response, @agiletortoise. That makes sense.

I’ve downloaded Mail Assistant and read through the docs. I’ve downloaded the Markdown email example so I could see how it was structured. I looked through the Actions directly to see if something already existed that does this.

I apologise if my ignorance is annoying here - I’m new to Drafts and still playing with it to work with my workflow. And I’m unclear still how to get it to do what I want it to do.

I want to be able to send an email from Drafts without seeing my inbox. I guess this involves using Mail Assistant to work with the Mail App but I don’t currently understand how to use the URL scheme to get it to do this. Thank you!

There are several options, which are discussed above, but it can be a bit confusing.

If your mail accounts are with Gmail or Outlook, you can send directly through those accounts with actions that communicate directly to Google or Microsoft’s APIs. There are links to example actions for this above and these work on both Mac and iOS.

Otherwise, you have to use a Mail app to send the email. On iOS, the “Mail” action is able to use Mail app without actually opening the app because Apple provides APIs to do that…those are not directly supported on Mac, so the “Mail” action step falls back to using “mailto:” URLs, which will open your default mail app to send mail.

The Mail Assistant uses Apple’s Catalyst technology to access the iOS APIs to send mail from a Mac. There is a sample action you can install that is linked in the Mail Assistant article (found here) that is already configured to use Mail Assistant on Mac. You do not need to worry about the URLs - just install Mail Assistant, and install this action in Drafts and use it, and you will get roughly the behavior you get on iOS with the Mail action. You will have to have your outgoing Mail accounts configured for use in Mail.app for it to work, even if you are using AirMail as your client.

The link above, with the text ”We have posted an example mailto-based action,“ incorrectly points to https://docs.getdrafts.com/misc/mail-assistant — clearly a copy-and-paste error from the immediately previous link.

I’d love to see the action, though. Any chance you could correct the link?

Thanks!

Fixed the link above. The Mailto is in the Directory. For future reference, that is generally where to start finding an action.

2 Likes

Thank you!

From the context of the original post, I’d thought that it would render my Markdown note in Drafts and render it as styled text in my mail client. Unfortunately, it seems to either give me plain text or HTML code in the message body. Same result whether I use Mail (which I don’t want to use, but figured I should test) or Fastmail (the client app I’d like to use).

I haven’t been able to find any useable iOS email app that supports Markdown composition, and I thought this would be away to accomplish that.

Any thoughts? I’m perfectly happy to do any of the addressing in the client app (I’ll be wanting to change the “from” address fairly often anyway) — but I really want to compose in Markdown, and I’d like to make more use of Drafts than I have over the years….

mailto is an old URL scheme specification…it predates HTML mail even being a thing and has no option to pass HTML to a client.

I would start by saying, why not just use the build in Mail app for sending? You can use something different for reading your mail, but if you have your mail account setup in iOS Settings, you can still use Drafts “Mail” action to send Markdown Mail on iOS (and/or the Mail Assistant route discussed above on Mac).

If you want to send HTML mail in other apps, they would have to have a custom URL scheme for composing that supports receiving HTML for the body content. A few have implemented this (I think AirMail?), but it’s not very common.