Docs / Integrations / E-commerce

E-commerce Integrations

Wire InboxOS into your store in minutes. Every order trigger, abandoned cart, and customer lifecycle event — sent reliably via SES on Cloudflare's edge.

Machine translation available — choose your language in the top bar.

Each integration ships as a thin adapter that receives a platform webhook or hook call, maps the event payload to a Mailgrid POST /api/emails request, and fires it. All adapters share the same two required environment variables:

VariableRequiredDescription
MAILGRID_KEYYesYour mb_live_… API key obtained from the contact form.
MAILGRID_FROMYesVerified sending address, e.g. orders@yourdomain.com.

Shopify

The Shopify integration is a Shopify CLI app (Node.js) deployed as a Cloudflare Worker that registers GDPR-compliant webhooks for order and cart events and forwards them to Mailgrid. It handles Shopify HMAC verification before touching any payload.

Setup

  1. Clone the adapter skeleton into your project:
    terminal
    git clone https://github.com/mailgrid/integrations integrations
    cd integrations/shopify
  2. Install dependencies and authenticate with the Shopify CLI:
    terminal
    npm install
    shopify app login --store your-store.myshopify.com
  3. Copy .env.example to .env and fill in your credentials (see env vars table below).
  4. Register the webhooks against your store:
    register-webhooks.mjs
    import { registerWebhook } from './src/shopify/webhooks.mjs';
    
    const topics = [
      'orders/create',
      'orders/fulfilled',
      'orders/cancelled',
      'checkouts/create',   // abandoned cart seed
      'checkouts/update',
      'customers/create',
      'refunds/create',
    ];
    
    for (const topic of topics) {
      await registerWebhook({
        topic,
        address: `${process.env.WORKER_URL}/webhooks/shopify`,
        format:  'json',
      });
      console.log(`registered: ${topic}`);
    }
  5. Deploy the Worker:
    terminal
    npx wrangler deploy

Key configuration

src/shopify/handler.mjs
import { verifyHmac, mapOrder } from './utils.mjs';

export async function handleShopify(request, env) {
  const hmac  = request.headers.get('X-Shopify-Hmac-Sha256');
  const topic = request.headers.get('X-Shopify-Topic');
  const body  = await request.text();

  if (!await verifyHmac(body, hmac, env.SHOPIFY_WEBHOOK_SECRET)) {
    return new Response('Forbidden', { status: 401 });
  }

  const payload = JSON.parse(body);

  if (topic === 'orders/create') {
    await fetch('https://api.mailgrid.space/api/emails', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${env.MAILGRID_KEY}`,
        'Content-Type':  'application/json',
      },
      body: JSON.stringify(mapOrder(payload, env.MAILGRID_FROM, env.ORDER_TEMPLATE_ID)),
    });
  }

  return new Response('ok');
}

Environment variables

VariableRequiredDescription
MAILGRID_KEYYesMailgrid API key (mb_live_…).
MAILGRID_FROMYesVerified sender address for order emails.
SHOPIFY_WEBHOOK_SECRETYesHMAC secret shown in Shopify Partners dashboard under Webhooks.
ORDER_TEMPLATE_IDNoMailgrid template UUID for order confirmation. Falls back to inline HTML if omitted.
ABANDONED_CART_DELAY_MSNoMilliseconds after checkouts/update before sending abandoned-cart email. Default: 3600000 (1 h).
MAILGRID_STREAM_IDNoStream ID to route all store email through a named transactional stream.

Supported events

WooCommerce

The WooCommerce integration is a drop-in PHP plugin that hooks into woocommerce_order_status_changed and related actions to dispatch transactional emails via Mailgrid instead of WooCommerce's built-in mailer. It overrides WC_Email at the transport layer so all existing email templates continue to work.

Setup

  1. Copy the plugin folder into your WordPress installation:
    terminal
    cp -r integrations/woocommerce wp-content/plugins/mailgrid-woocommerce
    cd wp-content/plugins/mailgrid-woocommerce && composer install
  2. Activate the plugin in WP Admin → Plugins.
  3. Navigate to WooCommerce → Settings → Mailgrid and enter your API key and from-address.
  4. Optionally map each WooCommerce email class to a Mailgrid template ID in the settings table.

Key configuration

includes/class-mailgrid-transport.php
class Mailgrid_Transport {

    public function __construct() {
        add_action( 'woocommerce_order_status_changed',
            [ $this, 'on_order_status_changed' ], 10, 4 );
        add_action( 'woocommerce_checkout_order_created',
            [ $this, 'on_order_created' ] );
    }

    public function on_order_status_changed( int $order_id, string $from,
                                               string $to, WC_Order $order ) {
        if ( $to === 'processing' ) {
            $this->send_via_mailgrid( $order, 'order_confirmation' );
        } elseif ( $to === 'completed' ) {
            $this->send_via_mailgrid( $order, 'order_fulfilled' );
        } elseif ( $to === 'cancelled' ) {
            $this->send_via_mailgrid( $order, 'order_cancelled' );
        }
    }

    private function send_via_mailgrid( WC_Order $order, string $event ) {
        wp_remote_post( 'https://api.mailgrid.space/api/emails', [
            'headers' => [
                'Authorization' => 'Bearer ' . get_option( 'mailgrid_api_key' ),
                'Content-Type'  => 'application/json',
            ],
            'body' => wp_json_encode( $this->build_payload( $order, $event ) ),
        ] );
    }
}

Environment variables

VariableRequiredDescription
MAILGRID_API_KEYYesStored in wp_options as mailgrid_api_key; can also be set via define('MAILGRID_API_KEY', '...') in wp-config.php.
MAILGRID_FROM_ADDRESSYesOverrides the WooCommerce "from" address for all outgoing email.
MAILGRID_STREAM_IDNoRoute all WooCommerce mail through a dedicated Mailgrid stream.
MAILGRID_TEMPLATE_MAPNoJSON object mapping WC email class names to Mailgrid template IDs, stored in wp_options.

Supported events

OpenCart

The OpenCart integration is a PHP extension that registers listeners in OpenCart's event system (3.x / 4.x). It intercepts model/checkout/order/addOrder/after and related events, then calls Mailgrid instead of the platform's default mail() wrapper.

Setup

  1. Upload the extension via Admin → Extensions → Installer and select mailgrid.ocmod.zip from integrations/opencart/.
  2. Navigate to Extensions → Extensions → Modules, find Mailgrid, and click Install, then Edit.
  3. Enter your API key, from-address, and optional template IDs, then click Save.
  4. Refresh the OpenCart modification cache: Admin → Extensions → Modifications → Refresh.

Key configuration

upload/system/library/mailgrid/client.php
class MailgridClient {

    private string $api_key;
    private string $from;

    public function __construct(string $api_key, string $from) {
        $this->api_key = $api_key;
        $this->from    = $from;
    }

    public function send(array $payload): void {
        $ch = curl_init('https://api.mailgrid.space/api/emails');
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => json_encode($payload),
            CURLOPT_HTTPHEADER     => [
                'Authorization: Bearer ' . $this->api_key,
                'Content-Type: application/json',
            ],
        ]);
        curl_exec($ch);
        curl_close($ch);
    }
}

// Event listener registered in extension controller:
// $this->event->register(
//   'model/checkout/order/addOrder/after',
//   new Action('extension/module/mailgrid/onOrderCreate'));

Environment variables

VariableRequiredDescription
mailgrid_api_keyYesStored in OpenCart oc_setting table under the extension's config group.
mailgrid_fromYesVerified sender address; replaces OpenCart's Store Email for transactional sends.
mailgrid_stream_idNoNamed Mailgrid stream to route store email through.
mailgrid_order_templateNoMailgrid template ID for order confirmation; uses built-in HTML if blank.
mailgrid_track_opensNoSet to 1 to enable open tracking pixel injection. Default: 0.

Supported events

Magento 2

The Magento 2 integration is a Composer package that registers a sales_order_place_after observer. It replaces Magento's Magento_Email transport for all transactional mail while keeping the existing template system intact. Compatible with Magento Open Source 2.4.x and Adobe Commerce.

Setup

  1. Require the package:
    terminal
    composer require mailgrid/magento2-transport
    php bin/magento module:enable Mailgrid_Transport
    php bin/magento setup:upgrade
    php bin/magento cache:flush
  2. Set the API key and from-address via the Magento CLI:
    terminal
    php bin/magento config:set mailgrid/transport/api_key "mb_live_…"
    php bin/magento config:set mailgrid/transport/from_address "orders@yourdomain.com"
    php bin/magento config:set mailgrid/transport/enabled 1
    php bin/magento cache:flush
  3. Verify by placing a test order or using Stores → Configuration → Advanced → System → Mail Sending Settings → Test.

Key configuration

Observer/OrderPlaceAfter.php
namespace Mailgrid\Transport\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Mailgrid\Transport\Model\ApiClient;

class OrderPlaceAfter implements ObserverInterface {

    public function __construct(
        private readonly ApiClient $client
    ) {}

    public function execute(Observer $observer): void {
        $order = $observer->getEvent()->getOrder();
        if (!$order || !$order->getCustomerEmail()) {
            return;
        }
        $this->client->send([
            'to'         => $order->getCustomerEmail(),
            'subject'    => 'Order #' . $order->getIncrementId() . ' confirmed',
            'templateId' => $this->client->templateFor('order_confirmation'),
            'variables'  => [
                'orderId'   => $order->getIncrementId(),
                'firstName' => $order->getCustomerFirstname(),
                'total'     => $order->getGrandTotal(),
            ],
        ]);
    }
}

Environment variables

VariableRequiredDescription
mailgrid/transport/api_keyYesMagento config path; set via CLI or Stores → Configuration. Can also be read from MAILGRID_KEY env var if the module detects it.
mailgrid/transport/from_addressYesVerified Mailgrid sender address.
mailgrid/transport/enabledYesSet to 1 to activate the transport. 0 falls back to Magento's default mailer.
mailgrid/transport/stream_idNoMailgrid stream ID for routing.
mailgrid/transport/template_mapNoJSON map of Magento email type codes to Mailgrid template IDs.

Supported events

PrestaShop

The PrestaShop integration is a native module that hooks into actionValidateOrder and the sendMail override to intercept all outbound mail. Compatible with PrestaShop 1.7.x and 8.x.

Setup

  1. Upload the module:
    terminal
    cp -r integrations/prestashop/mailgridtransport modules/
    cd modules/mailgridtransport && composer install --no-dev
  2. In Modules → Module Manager, search for Mailgrid Transport and click Install.
  3. Click Configure and enter your API key, from-address, and optional template IDs.
  4. Enable the Override sendMail toggle to intercept all PrestaShop system mail (recommended).

Key configuration

mailgridtransport.php
class MailgridTransport extends Module {

    public function install(): bool {
        return parent::install()
            && $this->registerHook('actionValidateOrder')
            && $this->registerHook('actionOrderStatusUpdate')
            && $this->registerHook('actionCustomerAccountAdd');
    }

    public function hookActionValidateOrder(array $params): void {
        $order    = $params['order'];
        $customer = new Customer((int) $order->id_customer);

        $this->mailgridSend([
            'to'         => $customer->email,
            'subject'    => $this->l('Order confirmed') . ' #' . $order->reference,
            'templateId' => Configuration::get('MAILGRID_ORDER_TEMPLATE'),
            'variables'  => [
                'reference' => $order->reference,
                'firstName' => $customer->firstname,
                'total'     => $order->getOrdersTotalPaid(),
            ],
        ]);
    }
}

Environment variables

VariableRequiredDescription
MAILGRID_API_KEYYesStored in PrestaShop ps_configuration as MAILGRID_API_KEY; configurable from the module settings page.
MAILGRID_FROMYesVerified sender address to use for all PrestaShop mail.
MAILGRID_OVERRIDE_SENDMAILNoSet to 1 to replace Mail::send() entirely. Default: 0 (hooks only).
MAILGRID_ORDER_TEMPLATENoTemplate ID for order confirmations.
MAILGRID_STREAM_IDNoMailgrid stream ID for routing.

Supported events

BigCommerce

BigCommerce does not expose server-side hooks, so the integration uses a Cloudflare Worker as a webhook receiver. The Worker registers BigCommerce webhooks via the Store Management API on first deploy and then relays events to Mailgrid. A register-webhooks.mjs script handles the registration step.

Setup

  1. Enter the integrations/bigcommerce/ directory and install dependencies:
    terminal
    cd integrations/bigcommerce
    npm install
  2. Copy .env.example to .env and fill in your BigCommerce API credentials and Mailgrid key.
  3. Register webhooks with the BigCommerce API:
    register-webhooks.mjs
    import { register } from './src/register.mjs';
    
    const scopes = [
      'store/order/created',
      'store/order/statusUpdated',
      'store/order/refund/created',
      'store/cart/abandoned',
      'store/customer/created',
      'store/shipment/created',
    ];
    
    for (const scope of scopes) {
      const result = await register({
        scope,
        destination: `${process.env.WORKER_URL}/webhooks/bigcommerce`,
        is_active: true,
      });
      console.log(`[${result.id}] ${scope}`);
    }
  4. Deploy the Worker:
    terminal
    npx wrangler deploy

Key configuration

src/worker.mjs
export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    if (url.pathname !== '/webhooks/bigcommerce') {
      return new Response('Not found', { status: 404 });
    }

    const { scope, data } = await request.json();

    if (scope === 'store/order/created') {
      const order = await fetchOrder(data.id, env);
      await sendOrderConfirmation(order, env);
    } else if (scope === 'store/cart/abandoned') {
      await env.ABANDONED.put(data.cartId,
        JSON.stringify(data),
        { expirationTtl: 86400 });
      // KV-backed delay: a second cron Worker reads and fires
    }

    return new Response('ok');
  }
};

Environment variables

VariableRequiredDescription
MAILGRID_KEYYesMailgrid API key, set as a Wrangler secret.
MAILGRID_FROMYesVerified sender address.
BC_CLIENT_IDYesBigCommerce API client ID from the store's Advanced Settings → API Accounts.
BC_ACCESS_TOKENYesBigCommerce V2/V3 access token.
BC_STORE_HASHYesHash portion of your BigCommerce API base URL, e.g. abc123.
WORKER_URLYesPublic URL of the deployed Worker used as the webhook destination.
MAILGRID_STREAM_IDNoMailgrid stream for routing all BigCommerce mail.

Supported events

Medusa.js

The Medusa.js integration is a notification subscriber that listens for Medusa events via the event bus and dispatches them to Mailgrid. It ships as a drop-in src/subscribers/mailgrid.ts file compatible with Medusa v1.x and v2 (the v2 module variant is in integrations/medusa/v2/).

Setup

  1. Copy the subscriber into your Medusa project:
    terminal
    cp integrations/medusa/src/subscribers/mailgrid.ts src/subscribers/
    cp integrations/medusa/src/services/mailgrid-client.ts src/services/
  2. Add the required env vars to your .env (see table below).
  3. Restart the Medusa server — subscribers are auto-discovered on startup.

Key configuration

src/subscribers/mailgrid.ts
import { SubscriberArgs, SubscriberConfig } from '@medusajs/medusa';
import MailgridClient from '../services/mailgrid-client';

export default async function mailgridOrderSubscriber({
  data, eventName, container,
}: SubscriberArgs<{ id: string }>) {
  const orderService = container.resolve('orderService');
  const order = await orderService.retrieve(data.id, {
    relations: ['customer', 'items', 'shipping_address'],
  });

  const client = new MailgridClient(process.env.MAILGRID_KEY!);

  await client.send({
    from:        process.env.MAILGRID_FROM!,
    to:          order.email,
    templateId:  process.env.MAILGRID_ORDER_TEMPLATE,
    variables: {
      orderId:    order.display_id,
      firstName:  order.customer?.first_name,
      total:      order.total / 100,
      currency:   order.currency_code.toUpperCase(),
    },
  });
}

export const config: SubscriberConfig = {
  event: [
    'order.placed',
    'order.shipment_created',
    'order.canceled',
    'order.refund_created',
    'customer.created',
  ],
};

Environment variables

VariableRequiredDescription
MAILGRID_KEYYesMailgrid API key added to your Medusa .env.
MAILGRID_FROMYesVerified sender address for all Medusa transactional mail.
MAILGRID_ORDER_TEMPLATENoTemplate ID for order.placed emails.
MAILGRID_SHIPMENT_TEMPLATENoTemplate ID for order.shipment_created emails.
MAILGRID_STREAM_IDNoMailgrid stream for routing Medusa mail.

Supported events

Swell

The Swell integration is a lightweight Cloudflare Worker that receives Swell webhooks, verifies the HMAC signature, and forwards order and customer events to Mailgrid. Swell fires webhooks for all lifecycle events over HTTPS; the Worker handles deduplication via Mailgrid's idempotency key.

Setup

  1. Deploy the Worker from integrations/swell/:
    terminal
    cd integrations/swell
    npm install
    npx wrangler secret put MAILGRID_KEY
    npx wrangler secret put SWELL_SECRET_KEY
    npx wrangler deploy
  2. In the Swell dashboard, go to Developer → Webhooks → Add endpoint and point it at https://your-worker.workers.dev/webhooks/swell.
  3. Select the events you want to receive (see list below) and save.

Key configuration

src/worker.mjs
import { verifySwellHmac, mapSwellEvent } from './utils.mjs';

export default {
  async fetch(request, env) {
    const sig  = request.headers.get('x-swell-signature');
    const body = await request.text();

    if (!await verifySwellHmac(body, sig, env.SWELL_SECRET_KEY)) {
      return new Response('Forbidden', { status: 401 });
    }

    const event   = JSON.parse(body);
    const payload = mapSwellEvent(event, env.MAILGRID_FROM);

    if (!payload) return new Response('ok'); // unhandled type

    await fetch('https://api.mailgrid.space/api/emails', {
      method:  'POST',
      headers: {
        'Authorization': `Bearer ${env.MAILGRID_KEY}`,
        'Content-Type':  'application/json',
        'Idempotency-Key': `swell-${event.type}-${event.data?.id}`,
      },
      body: JSON.stringify(payload),
    });

    return new Response('ok');
  }
};

Environment variables

VariableRequiredDescription
MAILGRID_KEYYesMailgrid API key, stored as a Wrangler secret.
MAILGRID_FROMYesVerified sender address.
SWELL_SECRET_KEYYesSwell webhook secret key from the dashboard, used for HMAC verification.
MAILGRID_STREAM_IDNoStream ID for routing Swell mail through a dedicated Mailgrid stream.
MAILGRID_ORDER_TEMPLATENoTemplate ID for order.created confirmation emails.

Supported events

Vendure

The Vendure integration is a NestJS plugin that subscribes to OrderStateTransitionEvent and other Vendure events via the EventBus. It wires cleanly into Vendure's DI container and can replace or supplement the built-in EmailPlugin.

Setup

  1. Install the plugin package:
    terminal
    npm install @mailgrid/vendure-plugin
  2. Register the plugin in your Vendure config:
    vendure-config.ts
    import { MailgridPlugin } from '@mailgrid/vendure-plugin';
    
    export const config: VendureConfig = {
      plugins: [
        MailgridPlugin.init({
          apiKey:     process.env.MAILGRID_KEY!,
          fromAddress: process.env.MAILGRID_FROM!,
          streamId:    process.env.MAILGRID_STREAM_ID,
          templates: {
            orderConfirmation: process.env.MAILGRID_ORDER_TEMPLATE,
            shipping:          process.env.MAILGRID_SHIP_TEMPLATE,
            customerWelcome:   process.env.MAILGRID_WELCOME_TEMPLATE,
          },
        }),
      ],
    };

Key configuration

mailgrid.plugin.ts
import { Injectable, OnModuleInit } from '@nestjs/common';
import { EventBus, OrderStateTransitionEvent } from '@vendure/core';
import { MailgridClient } from './mailgrid.client';

@Injectable()
export class MailgridEventHandler implements OnModuleInit {

  constructor(
    private eventBus: EventBus,
    private client:   MailgridClient,
  ) {}

  onModuleInit() {
    this.eventBus
      .ofType(OrderStateTransitionEvent)
      .subscribe(async (event) => {
        const { order, toState } = event;
        if (toState === 'PaymentSettled') {
          await this.client.send('orderConfirmation', order);
        } else if (toState === 'Shipped') {
          await this.client.send('shipping', order);
        } else if (toState === 'Cancelled') {
          await this.client.send('orderCancelled', order);
        }
      });
  }
}

Environment variables

VariableRequiredDescription
MAILGRID_KEYYesMailgrid API key passed to MailgridPlugin.init().
MAILGRID_FROMYesVerified sender address.
MAILGRID_STREAM_IDNoRoute all Vendure mail through this Mailgrid stream.
MAILGRID_ORDER_TEMPLATENoTemplate ID for PaymentSettled order confirmation.
MAILGRID_SHIP_TEMPLATENoTemplate ID for Shipped state notification.
MAILGRID_WELCOME_TEMPLATENoTemplate ID for new customer welcome email.

Supported events

CS-Cart

The CS-Cart integration is a PHP addon compatible with CS-Cart and Multi-Vendor 4.x. It uses CS-Cart's addon hook system to intercept order placement, status changes, and user registration events before the platform sends mail, replacing the default fn_send_mail() call with a direct Mailgrid API request.

Setup

  1. Upload and install the addon:
    terminal
    # Archive the addon directory
    cd integrations/cs-cart
    zip -r mailgrid_transport.zip app design
    # Then upload via Admin → Add-ons → Manage Add-ons → Upload
  2. In the CS-Cart admin, navigate to Add-ons → Manage Add-ons, find Mailgrid Transport, and set the status to Active.
  3. Click the gear icon next to the addon and enter your Mailgrid API key, from-address, and template mappings.

Key configuration

app/addons/mailgrid_transport/func.php
function fn_mailgrid_transport_send_order_notification(array &$order_info,
                                                         string $event_id): void {
    $api_key  = Registry::get('addons.mailgrid_transport.api_key');
    $from     = Registry::get('addons.mailgrid_transport.from_address');
    $template = Registry::get("addons.mailgrid_transport.template_{$event_id}");

    $payload = [
        'from'        => $from,
        'to'          => $order_info['email'],
        'subject'     => __('order_placed_subject') . ' #' . $order_info['order_id'],
        'templateId'  => $template ?: null,
        'variables'   => [
            'orderId'   => $order_info['order_id'],
            'firstName' => $order_info['firstname'],
            'total'     => fn_format_price($order_info['total']),
        ],
    ];

    fn_mailgrid_post($api_key, $payload);
}

// Hook registered in addon init:
// fn_register_hooks('place_order_post', 'change_order_status_post', 'create_profile_post');

Environment variables

VariableRequiredDescription
mailgrid_transport.api_keyYesStored in CS-Cart addon settings (Registry::get('addons.mailgrid_transport.api_key')).
mailgrid_transport.from_addressYesVerified Mailgrid sender address used for all outbound store mail.
mailgrid_transport.stream_idNoMailgrid stream ID for routing.
mailgrid_transport.template_order_placedNoTemplate ID for new-order confirmation emails.
mailgrid_transport.template_status_changedNoTemplate ID for order status change emails.
mailgrid_transport.override_allNoSet to Y to intercept all fn_send_mail() calls store-wide.

Supported events

nopCommerce

The nopCommerce integration is a C# plugin targeting .NET 7 / nopCommerce 4.60+. It implements IEmailSender and registers itself via the plugin's Services layer so that all outbound mail — orders, account notifications, newsletters — is dispatched through Mailgrid without any template changes required.

Setup

  1. Copy the plugin into your nopCommerce installation:
    terminal
    cp -r integrations/nopcommerce/Mailgrid.Nop.Plugin \
           Plugins/Mailgrid.Nop.Plugin
    dotnet build Plugins/Mailgrid.Nop.Plugin -c Release
  2. Restart the nopCommerce application. The plugin appears under Configuration → Local Plugins.
  3. Click Install, then Configure. Enter your Mailgrid API key, from-address, and optional stream ID.
  4. Under Configuration → Email Accounts, set the email account type to Mailgrid.

Key configuration

Services/MailgridEmailSender.cs
using Nop.Services.Messages;
using System.Net.Http.Json;

namespace Mailgrid.Nop.Plugin.Services;

public class MailgridEmailSender : IEmailSender
{
    private readonly MailgridSettings   _settings;
    private readonly HttpClient         _http;

    public MailgridEmailSender(MailgridSettings settings, IHttpClientFactory factory)
    {
        _settings = settings;
        _http     = factory.CreateClient("mailgrid");
        _http.DefaultRequestHeaders.Add(
            "Authorization", $"Bearer {settings.ApiKey}");
    }

    public async Task SendEmailAsync(
        EmailAccount emailAccount,
        string subject, string body,
        string fromAddress, string fromName,
        string toAddress,  string toName,
        string? replyTo = null,
        int delaySeconds = 0, string? attachmentFilePath = null,
        string? attachmentFileName = null,
        string? bodyEncoding = null)
    {
        var payload = new {
            from    = _settings.FromAddress,
            to      = toAddress,
            subject,
            html    = body,
            streamId = _settings.StreamId,
        };
        await _http.PostAsJsonAsync(
            "https://api.mailgrid.space/api/emails", payload);
    }
}

Environment variables

VariableRequiredDescription
Mailgrid:ApiKeyYesSet in appsettings.json under Mailgrid section, or as an environment variable Mailgrid__ApiKey following .NET config conventions.
Mailgrid:FromAddressYesVerified sender address for all nopCommerce outbound mail.
Mailgrid:StreamIdNoMailgrid stream ID for routing transactional mail.
Mailgrid:OrderTemplateNoTemplate ID override for order confirmation emails; falls back to inline HTML body from nopCommerce's message templates.
Mailgrid:TrackOpensNotrue / false. Injects open-tracking pixel. Default: false.
Mailgrid:TrackClicksNotrue / false. Rewrites links through the Mailgrid tracking endpoint. Default: false.

Supported events

Template inheritance

All integrations fall back to sending the platform's own rendered HTML body when no Mailgrid templateId is configured. Swap in a Mailgrid template at any time by setting the relevant *_TEMPLATE env var — no code changes needed.

Idempotency on retries

All adapters set an Idempotency-Key derived from the platform's native event or order ID. If your webhook infrastructure retries on timeout, Mailgrid will deduplicate and return the original messageId without re-sending. See Idempotency for TTL details.