Browse the docs

Send mail

Sends an email through the Mail app, or opens a draft for you to finish.

Send mail to to

Keyboard Maestro: MailSendMessage

Details #

Builds a new outgoing message in the Mail app and, by default, sends it. Mail must have an account set up. Switchboard talks to Mail with AppleScript, so the message goes out from whichever account Mail chooses, or from the sender you name in account.

to, cc, bcc and attachments each take either a list or one piece of text. Text is split at commas, semicolons and line breaks, so [email protected]; [email protected] is two recipients. Every address must contain an @. Attachments are file paths; ~ is expanded.

With send left at true, the message is sent in the background and no window opens. With send set to false, Mail comes to the front with the draft open and nothing is sent. That is the safe way to try a macro, and the only mode that works with no recipients.

The step has no output. The Trace note says who it was sent to, or that a draft was started.

Parameters #

ParameterTypeRequiredValuesWhat it does
accounttextThe sender to put on the message, set as the message's sender in Mail (normally the account's email address). If Mail does not accept it the setting is ignored and Mail picks one.
attachmentsany valueFile paths to attach, as a list or as text separated by commas, semicolons or line breaks. Every file must exist.
bcctextBlind copy recipients, same format as to.
bodytextThe message text. text is another spelling of body.
cctextCopy recipients, same format as to.
sendyes / notrue (the default) sends the message. false opens it as a draft.
subjecttextThe subject line. Empty by default.
texttextSame as body. If both are given, body wins.
totextRecipients, as a list or as text separated by commas, semicolons or line breaks. Needs at least one address across to, cc and bcc when send is true.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Start a draft in Mail (dry run only simulates it)
Do
  1. Start a mail to “[email protected]”
  2. Show “Draft started”
Open in Switchboard to try it

Gotchas #

  • The first time, macOS asks whether Switchboard Engine may control Mail. If you decline, the step fails; turn it on again in System Settings > Privacy & Security > Automation.

  • Fails with "x" isn't an email address when any recipient lacks an @.

  • Fails with mail.send needs at least one recipient (to, cc or bcc); set send to false to just start a draft when send is on and nobody is listed.

  • Fails with the attachment <path> doesn't exist when a file is missing.

  • Mail has no way to report a delivery failure afterwards, so a step that passes means Mail accepted the message.

See also #

Set mail status, Send message, Show notification