Email marketing

How we built a topic newsletter with e-mail campaigns inside PrestaShop

Shops that ask us for a newsletter usually share the same problem: PrestaShop's sends the same thing to everyone, and external platforms charge per subscriber, make you copy your products and keep the data away from the shop. We wanted a fully self-contained newsletter: customers choose their topics, merchants send campaigns with their products from their own e-mail accounts, and every send reaches the inbox.

Why it isn't trivial

  • Bulk e-mail no longer forgives. Gmail, Yahoo and Outlook demand SPF, DKIM, DMARC and one-click unsubscribe. One configuration mistake sends the whole campaign to spam.
  • Every provider has its limits. A Gmail account, Microsoft 365 or a hosting SMTP accept very different amounts per hour and per day, and exceeding them blocks the account mid-send.
  • The law is strict. GDPR requires prior, provable consent, double opt-in, a record of every change and easy unsubscribe.
  • It has to run on any hosting. No third-party libraries, PHP 7.1 to 8.5 and PrestaShop 1.6 to 9, with scheduled tasks that never block the server.

The approach: the whole cycle inside the shop

We designed the module around a complete journey, with no external services:

  • Topic subscriptions chosen by the customer in the footer, a pop-up, on registration or at checkout, with a consent checkbox and double opt-in.
  • A welcome coupon generated only when the e-mail is confirmed and, if the merchant wants, usable only with that e-mail's customer account.
  • A block-based campaign editor that takes products, prices and images straight from the catalogue.
  • Several sending accounts and a queue that splits the work into batches and pauses.
  • Tracking of every e-mail: delivery, proof of receipt by open or click, unsubscribes, bounces and attributed orders.

Technical decisions

Our own mail client

The usual mail libraries don't pass the PrestaShop Addons validator, so we wrote our own MIME builder and SMTP client: multipart messages with a text version, images embedded in the e-mail so they show even when the mail app blocks remote ones, and List-Unsubscribe headers with one-click unsubscribe per RFC 8058.

Gmail and Microsoft 365 without storing passwords

Besides classic SMTP and Gmail and Yahoo app passwords, the module connects to Google and Microsoft through OAuth and sends via the Gmail API and Microsoft Graph. Merchants use their own Google or Azure client, and tokens are stored encrypted with AES-256 and an HMAC signature.

Validate before sending

An account can't send campaigns until a test e-mail goes out. The module also queries the sender domain's DNS and checks SPF, DKIM (trying the most common selectors) and DMARC, with specific warnings for Gmail, Yahoo and Outlook.

Limits that enforce themselves

Each account stores its hourly and daily limits, batch size, pause between batches and delay between e-mails. The scheduled task checks how much each account has sent in the hour and the day, sends only what fits and pauses the campaign until the next batch. The editor estimates how long the send will take before it is scheduled.

Consent as a record, not a checkbox

Every sign-up, confirmation, topic change and unsubscribe is logged with date, IP, source and a fingerprint of the accepted text. Links in every e-mail are HMAC-signed, so nobody can unsubscribe or change another subscriber's preferences.

Tested on all four versions

We tested every flow on PrestaShop 1.6, 1.7, 8 and 9: sign-up with and without an account, import from the native newsletter, sends against a test SMTP server with batches, pauses and bounces, click tracking and order attribution. Along the way we solved differences between versions, such as the way PrestaShop 1.6 alters incoming JSON data.

What we learnt

Whether an e-mail arrives depends less on design than on reputation: a well-configured domain, a reasonable sending pace and lists of people who really want to hear from you. That is why the module nudges merchants towards those good practices on every screen. It is the same approach we bring to the integrations, automations and custom developments we build for our clients.

What this development demonstrates

  • Topic subscriptions with GDPR-compliant consent and double opt-in
  • Own MIME builder and SMTP client, no third-party libraries
  • Sending through the Gmail API and Microsoft Graph with OAuth and encrypted tokens
  • SPF, DKIM and DMARC checks and one-click unsubscribe (RFC 8058)
  • Sending queue with batches, pauses and per-account limits
  • Tracking of deliveries, clicks and attributed orders on PrestaShop 1.6 to 9