Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Lets a FluentCRM email send From a founder address instead of hello@, for person
- **Founder emails go through SES only, with no backup retry** (`gravitysmtp_connector_for_sending`, priority 99, Gravity SMTP's `force` form). Everything else keeps SES first and Mailgun as backup (`GRAVITYSMTP_INTEGRATION_PRIMARY` / `_BACKUP` in `wp-convesio.php`). SES signs as `gravitykit.com` with the bounce domain `ses.gravitykit.com` and adds no `Sender:` header. Mailgun, the first choice until 2026-12-04, adds `Sender: zack=gravitykit.com@mg.gravitykit.com`, which Outlook shows as "on behalf of", so a personal email looked automated. If SES is down, a founder email fails rather than falling back.
- **SES only sends From addresses its IAM policy lists.** The user `ses-gravitykit-website` (AWS account 019006345227, inline policy `SesGravityKitWebsiteSendingPolicy`) allows `ses:FromAddress` hello@ and zack@gravitykit.com (widened 2026-12-04). A new founder address needs adding there too, or SES refuses its emails. Check with `aws iam simulate-principal-policy` and the `ses:FromAddress` context key.
- **Sender picker:** FluentCRM's From Email box becomes a dropdown (still accepts typing) when `fluent_crm/verfied_email_senders` (FluentCRM's spelling) returns addresses. `addPickerSenders()` adds FluentCRM's global From address and every allowlisted sender. FluentCRM fills that list from FluentSMTP only, which we don't use, so it was empty before.
- **Founder emails carry `List-Id: GravityKit founder emails <founder-emails.gravitykit.com>`** (unless one is already set), so a Gmail filter can match them with `list:founder-emails.gravitykit.com`. Gmail filters cannot match `X-` headers.
- **Founder emails carry `List-Id: <founder-emails.gravitykit.com>`** (unless one is already set), with no display name: Gravity SMTP builds SES emails with PHPMailer's `mail` line limit, which Q-encodes any custom header over 47 characters and so mangled the longer `GravityKit founder emails <…>` form on 2026-12-04, so a Gmail filter can match them with `list:founder-emails.gravitykit.com`. Gmail filters cannot match `X-` headers.
- **Gravity SMTP "Resend" sends From hello@** (a new request, no token).
- **Settings writes while armed keep the stored sender.** Gravity SMTP's `Opts_Data_Store::save()` writes back the whole option as read, so `pre_update_option_gravitysmtp_<connector>` puts the stored From, name and Reply-To back (`keepStoredSender()`). Without it, an OAuth token refresh mid-send or a save after an attempt that never wrote its status would store the founder address.
- Filters: `customcrm/founder_sender/enabled`, `customcrm/founder_sender/senders`, `customcrm/founder_sender/connector` (default `amazon`, Gravity SMTP's name for SES).
Expand Down
5 changes: 4 additions & 1 deletion classes/Email/FounderSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ class FounderSender {
/**
* Added to every founder email. Gmail filters cannot match `X-` headers but can match this one:
* `list:founder-emails.gravitykit.com`.
*
* No display name: Gravity SMTP builds SES emails with PHPMailer's `mail` line limit, which
* encodes any custom header value over 47 characters, and an encoded `<id>` is not a valid List-Id.
*/
public const LIST_ID = 'GravityKit founder emails <founder-emails.gravitykit.com>';
public const LIST_ID = '<founder-emails.gravitykit.com>';

/**
* Founder emails must stay on the domain whose DMARC alignment was checked.
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/FounderSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ public function test_founder_email_gets_list_id_for_gmail_filters() {
$this->assertContains( 'List-Id: ' . FounderSender::LIST_ID, $atts['headers'] );
}

/**
* PHPMailer Q-encodes a custom header value longer than 63 - (8 + strlen('us-ascii')) characters
* when building SES emails, which breaks the `<id>` Gmail's `list:` filter matches on.
*/
public function test_list_id_is_short_enough_to_send_unencoded() {
$this->assertLessThanOrEqual( 47, strlen( FounderSender::LIST_ID ) );
$this->assertMatchesRegularExpression( '/^<[a-z0-9.-]+>$/', FounderSender::LIST_ID );
}

public function test_list_id_is_not_added_to_other_emails_or_duplicated() {
$plain = $this->send( [ 'From: Team GravityKit <hello@gravitykit.com>' ] );
$this->assertSame( [ 'From: Team GravityKit <hello@gravitykit.com>' ], $plain['headers'] );
Expand Down
Loading