Send an email to all customers, with Mechanic.

Mechanic is an automation development platform for Shopify. :)

Send an email to all customers

by Isaac Bowen (team@usemechanic.com)

Use this task to easily contact all of your customers at once, optionally filtering by customer tag. Important: This task can only be used in a transactional context - it cannot be used be used for marketing emails, or any type of message that would require an unsubscribe link.

Runs when a user triggers the task. Configuration includes only send to customers having this tag, email subject, and email body.

15-day free trial – unlimited tasks

Documentation

This task will send your preconfigured email to all of your customers, optionally filtering by preconfigured tag. Make sure to double-check your task configuration before sending!

Important: This task can only be used in a transactional context - it cannot be used be used for marketing emails, or any type of message that would require an unsubscribe link. Read more: What kind of email can I send with Mechanic?

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Events
when a user triggers the task (mechanic/user/trigger)
Options
only send to customers having this tag, email subject (required), email body (required, multiline)
Script
{% comment %}
  Express an opinion about option order

  {{ options.only_send_to_customers_having_this_tag }}
  {{ options.email_subject__required }}
  {{ options.email_body__required_multiline }}
{% endcomment %}

{% if event.preview %}
  {
    "action": {
      "type": "email",
      "options": {
        "to": "customer@example.com",
        "subject": {{ options.email_subject__required | strip | json }},
        "body": {{ options.email_body__required_multiline | strip | newline_to_br | json }},
        "reply_to": {{ shop.customer_email | json }},
        "from_display_name": {{ shop.name | json }}
      }
    }
  }
{% else %}
  {% for customer in shop.customers %}
    {% assign customer_qualifies = true %}

    {% if customer.email == blank %}
      {% assign customer_qualifies = false %}
    {% endif %}

    {% if options.only_send_to_customers_having_this_tag != blank %}
      {% assign customer_tags = customer.tags | split: ", " %}
      {% unless customer_tags contains options.only_send_to_customers_having_this_tag %}
        {% assign customer_qualifies = false %}
      {% endunless %}
    {% endif %}

    {% if customer_qualifies %}
      {
        "action": {
          "type": "email",
          "options": {
            "to": {{ customer.email | json }},
            "subject": {{ options.email_subject__required | strip | json }},
            "body": {{ options.email_body__required_multiline | strip | newline_to_br | json }},
            "reply_to": {{ shop.customer_email | json }},
            "from_display_name": {{ shop.name | json }}
          }
        }
      }
    {% endif %}
  {% endfor %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.