The "email" action

Email runs everything. Mechanic sends email. So long as you're sending transactional email only, you're covered. 👌

Read more: What kind of email can I send with Mechanic?

Did you know you can receive email with Mechanic? It's true!

Options

  • "to" – required
  • "cc" – optional
  • "bcc" – optional
  • "subject" – required
  • "body" – required; allows HTML and CSS
  • "reply_to" – optional
  • "from_display_name"  – optional; will be combined with the shop's assigned sender address
  • "template" – defaults to "default"; used to specify an email template from the store's Mechanic settings
  • "attachments" – optional; an object of file names and file values

Notably, the "from" address is not configurable at the action level. By default, messages are sent from an email address at mail.usemechanic.com, where the mailbox is named after the store's myshopify.com subdomain. (To illustrate, the store fantastic.myshopify.com would have its mail sent from fantastic@mail.usemechanic.com.)

To change the "from" address of your outgoing mail, see Sending email from a custom address.

Attachments

Mechanic will auto-detect file types based on file names, and attach them appropriately. For example, to attach a simple CSV, use this:

"attachments": {
  "simple.csv": "Question,Answer\nIs it simple?,Yes"
}

Mechanic also supports generating richer file types, like PDFs and zip files, and base64-encoded data. To learn more about this, see Generating files.

Examples

{% action "email" %}
  {
    "to": "hello@example.com",
    "subject": "Hello world",
    "body": "It's a mighty fine day!",
    "reply_to": {{ shop.customer_email | json }},
    "from_display_name": {{ shop.name | json }}
  }
{% endaction %}

This example hard-codes the recipient, the subject, and the body. It then uses your shop's customer service email as the "reply-to" header, and uses the shop's own name as the display name for the "from" header.

Try using Liquid filters to make using captured values easy:

{% capture email_body %}
  <b>Hello!</b>

  It's fantastic to see you!
{% endcapture %}

{% action "email" %}
  {
    "to": "hello@example.com",
    "subject": "Hello world",
    "body": {{ email_body | unindent | strip | newline_to_br | json }}
  }
{% endaction %}

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.