Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,220 of 9,220 pages
About the help in other languages
All help pages

Deliverability: bounces, retries, rate limits, test groups, mail-in, suppression import

cjw_newsletter 4.2.0. This page covers how the newsletter's mails reach their readers and what it does when they do not. Everything works through the e-mail preferences of Exponential 6.0.15 and later: the suppression…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/ext/cjw_newsletter/deliverability.md

On this page

Deliverability: bounces, retries, rate limits, test groups, mail-in, suppression import

cjw_newsletter 4.2.0. This page covers how the newsletter's mails reach their readers and what it does when they do not. Everything works through the e-mail preferences of Exponential 6.0.15 and later: the suppression list, the consent log, the bounce reader and the double opt-in. The newsletter keeps no parallel system.

FeatureWhereSettings
Hard bounces and complaints go on the suppression listautomaticcjw_newsletter.ini [DeliverabilitySettings]
Soft bounces and temporary refusals are sent againautomatic[DeliverabilitySettings]
Rate limits per transport, batches, pauses, resumable sendingNewsletter > Rate limits and batches (newsletter/throttle)[ThrottleSettings]
Test groups for the test sendsNewsletter > Test groups (newsletter/test_group_list)[TestSendSettings]
Subscribe and unsubscribe by e-mailNewsletter > Mail-in addresses (newsletter/mailin_address_list)[MailInSettings], mailpreferences.ini [BounceSettings]
CSV import into the suppression listNewsletter > Suppression import (newsletter/suppression_import)[DeliverabilitySettings] SuppressionImportMaxRows

All the admin pages, and the block "Deliverability" on the newsletter dashboard, need the policy function newsletter/deliverability. The console command is ext:cjw_newsletter:deliverability (see the end of this page).

1. Bounces

A returned mail reaches the newsletter in one of two ways:

  • through a newsletter mail account (Newsletter > Mail accounts, ext:cjw_newsletter:mailbox, the cronjob part cjw_newsletter_mailbox), as before;
  • through the bounce reader of the e-mail preferences (exp:mail:bounces, the cronjob part mailbounces). The extension's settings/mailpreferences.ini.append.php names CjwNewsletterMailin in [BounceSettings] MessageListeners[], so every message the kernel reader reads is also given to the newsletter. The reader stays off until its mailbox is set in a settings override.

The kind of the message comes from the kernel's classifier (expMailBounceReader::classify(): delivery status notifications and feedback loop reports). A message the kernel cannot read is judged by the SMTP code in it. The mail and the person are found by the newsletter's own headers (X-Cjwnl-Senditem, X-Cjwnl-User), which a mail server copies into the returned message.

KindWhat happens
hard (the address or the domain does not exist: the kernel's [BounceSettings] HardStatusCodes[], 5.1.x, 5.2.1, 5.4.4 by default)The address goes on the suppression list with the reason bounce. The consent log records it (action suppress, source system). The suppression listener of the newsletter puts the address on the newsletter blacklist. No optional mail of the site goes to it any more, not only the newsletter.
complaint (a spam report of a feedback loop)The same, with the reason complaint.
soft (a full mailbox, a server that is down, a policy refusal such as 5.7.x)The newsletter user's bounce count rises as before ([BounceSettings] BounceThresholdValue). The mail is sent again (section 2).
delay (a delivery status notification that only says the mail is delayed, action delayed, e.g. 4.2.2; the server keeps trying)Nothing. The send item and the user stay as they are and no retry is scheduled: the mail may still arrive, and the server reports the final result later.
autoreply (an out-of-office reply or other automatic message that is not a delivery status notification: Auto-Submitted other than no, or Precedence bulk, junk or list)Nothing, even if the text quotes a reply code such as 450. A real bounce that carries such a header is still a bounce: the kernel's classification wins, and a delivery report (multipart/report) or a message from MAILER-DAEMON@ or postmaster@ is never taken for a reply.

One classification per message. A newsletter mail account makes one classification of each stored message (CjwNewsletterBounce::classify()), and that one classification gives the code recorded with the item, the kind in the parse log and the action taken. The code (bounce_code) is the enhanced status code of the recipient that decided the kind (for example 5.1.1), the feedback type of a report (for example abuse), the kind itself when the classifier gives no code, or 0 when the message is no bounce, a delay notice or an automatic reply. There is no second, code-based parser any more.

Without the kernel. When the kernel's classifier is not available, the newsletter judges a delivery status notification by the status or diagnostic code of any of its recipients (a permanent one first, not only the first recipient), wherever the status part stands in the message, and without one by the first text part. A text that only looks like a status (5x1y1) is not read as one.

The parse log of a mail account item (parse_result) carries the kind (bounce_kind) and, when the kernel gives one, the reason (bounce_reason, for example mailbox-full or unknown-address; empty when the newsletter judged the message by its SMTP code). The reason is only recorded: it changes none of the actions above.

Two thresholds, independent. [BounceSettings] BounceThresholdValue of the newsletter sets when a subscriber's status becomes bounced. The kernel's [BounceSettings] SoftBounceThreshold (mailpreferences.ini, off by default) suppresses an address site-wide after that many soft bounces within SoftBounceWindowDays; newsletter mail counts because it passes the kernel's gate. The newsletter never suppresses an address for soft bounces itself. A suppression made by the kernel reaches the newsletter blacklist through the suppression listener, like every other suppression.

With SuppressHardBounces=disabled, a hard bounce only marks the newsletter user as bounced, as before 4.2.0.

A mail the mail server refuses at once while the queue sends it is handled the same way. A permanent failure is a hard bounce. A temporary refusal (4xx) or a server that cannot be reached is sent again. Other errors, such as a mail file that cannot be written, close the item as before. A 450 reply is no longer taken for a hard bounce.

A newsletter mail account deletes messages from the server (delete_mails_from_server) only after they are stored: a message that is stored, or already known, is deleted; a message that cannot be stored stays on the server and is tried again at the next run. For IMAP the deleted messages are expunged at the end of the run, POP3 removes them when the connection closes. A mail account that fails to connect or to fetch is logged with its id and does not stop the other accounts.

Folder, processed folder and timeout. A mail account of the type IMAP has two more fields. The IMAP folder is the folder the account reads; empty means INBOX. The processed folder is where the messages go once they are stored (or already known); empty means they are not moved and the delete flag rules as above. The two folders must differ. With a processed folder the messages are moved instead of deleted: with the mail package's MOVE command (moveMessages()) when the package has it, otherwise copied, deleted and expunged. A processed folder that does not exist is created once and the move tried again; if the move still fails the error is logged (move-failed, with the mailbox id, the folder and the reason) and nothing is deleted, so the messages are found again at the next run. A message that cannot be stored is never moved. POP3 has no folders and ignores both fields. The time to wait for the mail server when connecting (IMAP and POP3) is cjw_newsletter.ini [BounceSettings] MailboxConnectTimeout, in seconds, at least 1, default 3.

An existing installation adds the two columns with update/database/<engine>/4.3/dbupdate-4.3.3-to-4.3.4.sql (run once).

The suppression list is the kernel's: Setup > E-mail preferences > Suppression list shows and lifts entries. A lifted address also comes off the newsletter blacklist.

OAuth 2.0 for newsletter mail accounts

Some mail providers accept no password for IMAP or POP3 and want an OAuth 2.0 access token (the SASL mechanism XOAUTH2). A newsletter mail account can log in that way. The settings are per account, keyed by the account's user name, and belong in the unversioned settings override, not in the versioned INI:

[MailboxAuthSettings]
AuthMethod[[email protected]]=xoauth2
TokenSource[[email protected]]=file:/srv/tokens/reader.token
  • AuthMethod is empty by default: the stored password is used for a plain login, as before. xoauth2 works for IMAP; for POP3 it needs a mail package that supports it, otherwise the account reports an error instead of logging in.
  • TokenSource names where the current token is read at each connect: file:<path>, env:<name> or class:<name>. Left empty, the password field of the account holds the token. A token that is missing or empty gives the error "no token for mailbox <user name>"; no login is attempted.
  • The token is never stored in the account, never put into the logged settings and never written to the newsletter log. Getting and refreshing the token is the job of a process outside the CMS that writes the token file.

The bounce reader of the e-mail preferences (mailpreferences.ini [BounceSettings]) has the same two settings (plus apop for POP3), AuthMethod and TokenSource. The token source forms, the file permissions, the package version and the cache rule after changing settings are described in doc/eng-us/features/6.0/mail-oauth2.md of Exponential.

2. Soft bounces: sending again

[DeliverabilitySettings]
SoftBounceMaxRetries=2      # 0 = never again
SoftBounceRetryDelay=3600   # seconds before the first retry; each further retry waits twice as long
SoftBounceRetryMaxAge=3     # days: an older send is not opened again

A soft-bounced item goes back to "not sent" with a time before which it is not taken (cjwnl_edition_send_item.next_retry, retry_count). A send that had finished is opened again until the retry is done. No retry is made for a user who is bounced, blacklisted, removed or suppressed. The dashboard and the throttle page show how many mails wait for a retry. A delivered mail sets the user's soft-bounce count back to 0.

3. Rate limits, batches and pauses

[ThrottleSettings]
Throttle=enabled
BatchSize=200
PauseBetweenBatches=0
MaxPerMinute[smtp]=120
MaxPerHour[smtp]=5000
  • With Throttle=enabled, each send goes out in batches (cjwnl_send_batch). A batch takes at most BatchSize mails, and no more than the limits of the transport allow in the current minute and hour.
  • When a limit is reached, the send stops. It is resumed by the next run of the queue (the cronjob, or "Send now"), from where it stopped.
  • PauseBetweenBatches holds the next batch of a send until that many seconds after the previous one finished. No run waits or sleeps: a later run starts the batch.
  • The limits are per transport (smtp, sendmail, file, and the SMS transports of the SMS area, which use the same counter). A send is counted under the newsletter transport it was made with (cjwnl_edition_send.throttle_transport).
  • Pause: Newsletter > Rate limits and batches pauses a transport for some minutes (or ext:cjw_newsletter:deliverability pause). A paused transport sends nothing, even with Throttle=disabled. The dashboard lists the pause as a warning.

For other code: CjwNewsletterThrottle::acquire( $transport, $wanted ) returns how many may be sent now (0 = wait), and CjwNewsletterThrottle::record( $transport, $sent ) counts what was sent.

With queue delivery ([QueueDeliverySettings] QueueDelivery=enabled and expqueue) the same limits apply to the delivery jobs: each run of a send's job is one batch (also with Throttle=disabled, of at most BatchSize items), and the job comes again when the limit, the pause or PauseBetweenBatches lets the next batch go. The transports run one batch at a time ([QueueResource_cjw_newsletter.<transport>] MaxConcurrent=1).

4. Test groups

Newsletter > Test groups: a named set of addresses, for one list or for every list, at most MaxTestGroupSize. The test send form of an edition offers the groups of its list. The group's addresses are added to the addresses typed into the form.

Every test mail is marked:

  • the subject starts with [TestSendSettings] SubjectPrefix ([Test]);
  • the header X-Cjwnl-Test: 1 is set;
  • with OneMailPerAddress=enabled (the default), each address gets a mail of its own, so testers do not see each other's addresses.

Test mails go through the preview transport (TransportMethodPreview). They never pass the mail gate and are never counted in the statistics.

5. Subscribe and unsubscribe by e-mail

Newsletter > Mail-in addresses: an address of a list that takes subscribe and unsubscribe mails. Switch the feature on with [MailInSettings] MailIn=enabled.

FieldMeaning
Address[email protected]: the mails must arrive in the bounce mailbox of the e-mail preferences, or in the newsletter mail account chosen as Mailbox
Plus tagweekly makes the address [email protected] (PlusAddressing=enabled). Without a row of its own, news+subscribe@ and news+unsubscribe@ reach news@ with the tag as the request
Takessubscribe, unsubscribe, or both (the keyword in the plus tag, the subject or the first line decides: SubscribeKeywords[], UnsubscribeKeywords[])
ListThe list; "every list" only takes unsubscribe mails

The From header is never trusted alone.

  • Subscribe:
    • A new address gets a pending subscription and the newsletter's normal confirmation mail. The person must open its link (double opt-in), as with the subscribe form.
    • A known address gets the mail with the link to its own settings page, where the person subscribes.
    • The message itself confirms nothing. A suppressed or blacklisted address gets no mail.
  • Unsubscribe:
    • The mail is honoured at once when it proves the address. That means a reply to an edition that quotes the newsletter's header X-Cjwnl-User of that person, or a mail that contains the code of the person or of the subscription.
    • Otherwise the address on record gets a mail with its unsubscribe links (template design:newsletter/deliverability/mail/mailin_unsubscribe.tpl).
    • An unknown address gets no answer, so a mail does not reveal who is subscribed.
  • Rejected:
    • automatic messages (Auto-Submitted, Precedence: bulk/junk/list);
    • IgnoreSenders[] and the site's own addresses;
    • a sender with more than MaxRequestsPerSenderPerDay requests;
    • a message without a request.
  • Every message is handled once, by its Message-Id. The table cjwnl_mailin_message and the list "Last messages" keep what was done. Privacy: the sender's address is kept masked once the message is handled.

6. Suppression import

Newsletter > Suppression import: a CSV file (or pasted addresses) into the kernel suppression list.

  • Typical sources: a do-not-contact list (Robinson list), the bounces of an earlier mail system, legal requests.
  • The file: one address per row, in a column email (also e-mail, mail, address) or, without such a header, the first column with an address. ;, ,, tab or | between columns; at most SuppressionImportMaxRows rows.
  • Reason: legal, admin, bounce, complaint or unsubscribe_all. bridge belongs to the newsletter blacklist and cannot be chosen.
  • Check counts and changes nothing: rows, valid addresses, duplicates, already suppressed, and the lines that hold no address.
  • Import adds the new addresses. An address that is already suppressed keeps its entry and reason. Each new entry is written to the consent log (action suppress, source import) and mirrored on the newsletter blacklist.
  • Privacy: the uploaded file is read and forgotten. The suppression list stores only a salted hash of each address, and addresses are taken out of the note.

7. The console

./console ext:cjw_newsletter:deliverability status [--json]
./console ext:cjw_newsletter:deliverability suppression-import --file=list.csv --reason=legal [--note="..."] [--dry-run]
./console ext:cjw_newsletter:deliverability pause --transport=smtp --minutes=30 [--dry-run]
./console ext:cjw_newsletter:deliverability resume --transport=smtp [--dry-run]
./console ext:cjw_newsletter:deliverability read --file=saved.eml|directory [--mailbox=<id>] [--dry-run]

read handles saved messages the way the mailbox readers would: a bounce of a newsletter mail, or a mail to a mail-in address. With --dry-run it says what would happen. Every action ends with PASS or FAIL and exits 0 or 1.

8. Tables and extension points

  • Tables: cjwnl_throttle_state, cjwnl_send_batch, cjwnl_mailin_address, cjwnl_mailin_message, cjwnl_test_group. Columns: cjwnl_edition_send.test_group_id (reserved), .throttle_transport; cjwnl_edition_send_item.retry_count, .next_retry, .batch_id; cjwnl_user.soft_bounce_count, .last_bounce (doc/schema-4.2.md).
  • The handler CjwNewsletterDeliverabilityHooks uses the points sendProcessAllowed (pause), itemBeforeSend (a full batch defers the send), itemSent (batch counts), testSendRecipients, sendFormStored (the transport of the send) and dashboardSummary.
  • The runner takes the batch of a send after the points have allowed it, leaves out the items that wait for a retry, and hands a refused mail to CjwNewsletterBounce::sendFailed().
  • Template parts: design:newsletter/dashboard/deliverability.tpl, design:newsletter/deliverability/send_form_part.tpl, design:newsletter/deliverability/test_form_part.tpl. Fetch function: fetch( 'newsletter', 'test_group_list', hash( 'list_contentobject_id', $id ) ).
  • Tests: tests/tests/extension/cjw_newsletter/cjwNewsletterDeliverabilityTest.php of the Exponential installation, with the messages in fixtures/deliverability/, and the kernel's MailPreferencesBounceListenersTest.

Something wrong on this page? Report an error

Documentation license

This page is part of the documentation of the extension cjw_newsletter and is distributed under the license of that extension.