Repository navigation
[WEBSITE-723] Add a Personal reply template that threads with the automation's last email - #87
Merged
Merged
Conversation
… email A founder check-in reads as a reply when it follows a marketing email: "Re:" subject, In-Reply-To/References and the earlier email quoted below, so mail apps show one conversation. The earlier email is the contact's last sent one from the same automation, found automatically. SES and Mailgun replace WordPress's Message-ID, so each automation email's real one is read from the provider response (http_api_debug) and stored in fc_meta. Gravity SMTP's SES connector builds the email with PHPMailer in mail mode, which encodes headers over 47 characters; a reply switches it to smtp mode for that email only. Gravity SMTP also drops a header whose value repeats another's, which removed References on a first reply. With no earlier email or no stored Message-ID, the email goes out as a plain Personal email under its own subject. Part of WEBSITE-723
Reads the earlier email's body in the same query that finds it, skips the header split for emails without the marker, tracks the PHPMailer switch as a flag, unserializes stored headers with FluentCRM's safeUnserialize, and registers both Personal templates in one loop. Part of WEBSITE-723
FluentCRM clears a sent email's body, so the reply quoted a new render of the campaign: today's copy, prices and carts, and cart merge tags could create a new discount code. In an automation with a Personal reply step, each email's sent HTML (pixel removed, tracked links restored) is now stored with its Message-ID and quoted as sent. The earlier email must also come from the contact's current run, so a second cart or renewal run never replies to last year's email. PHPMailer goes back to mail mode at the start of every send, since the log status update that restored it never fires with Gravity SMTP logging off, and a reply with a Bcc stays in mail mode because smtp mode leaves Bcc out of the built email. References keeps 8 IDs, under PHPMailer's 982-character encoding limit. A fallback with an earlier email but no stored Message-ID is logged, and customcrm/personal_reply/enabled turns the reply feature off on its own. Part of WEBSITE-723
The check only matched 'new \CustomCRM\...', so a missing class behind a static register() call, such as PersonalReply, would pass it and fatal on the site. Part of WEBSITE-723
…sender Each Personal reply's stored row now names the email it replied to, or why it went out as a plain Personal email (no_earlier_email, no_message_id, no_subject, database_error), so fallbacks can be counted with SQL. The From stored with each email is the one in the SES or Mailgun request, since Gravity SMTP can replace FluentCRM's, and the quote's "wrote:" line uses it. Stored rows are deleted with their contact (fluentcrm_before_subscribers_deleted) and after 180 days by a daily event, in batches. The option customcrm_personal_reply_off turns the feature off with WP-CLI, no deploy needed. Part of WEBSITE-723
Without a platform pin, an install on PHP 8.x picks doctrine/instantiator 2.x, whose typed constants break the PHPUnit run on 7.4, the plugin's minimum. composer.lock and vendor/ are not committed or deployed, so this changes test tooling only. Part of WEBSITE-723
… checks Part of WEBSITE-723
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A founder check-in that follows a marketing email in an automation can now go out as a real reply: "Re: ",
In-Reply-ToandReferencespointing at the earlier email, and the earlier email quoted below in Gmail's format. Mail apps then show one conversation, like a person replying to their own newsletter. Pick "Personal reply" in the template picker, next to "Personal". Nothing is chosen per email: the reply goes to the contact's last sent email from earlier in the same run of that automation. With nothing to reply to, it goes out as a plain Personal email under its own subject.For review: the reply changes PHPMailer's shared
Mailertosmtpfor one SES send and puts it back afterwards. Check that no path leaves it insmtpmode for a later email.Part of WEBSITE-723
What changed
PersonalTemplate: a second template,gk_personal_reply, rendered and untracked exactly likegk_personal.PersonalReply(new):SendRawEmail) or Mailgun response throughhttp_api_debug. SES and Mailgun replace WordPress's own.fc_meta, with the From that actually went out. In automations that have a reply step, it also stores the sent HTML, with the open pixel removed and links untracked.fc_funnel_subscribers.created_at). It then sets the subject, the two headers and the quote.mailmode, which encodes headers over 47 characters. A reply switches it tosmtpmode ongravitysmtp_after_connector_init, except when the email has a Bcc. It switches back at the next send and on the log update.Referencesis moved to a string key.wp option update customcrm_personal_reply_off 1.deploy.yml: the class check also covers classes the bootstrap calls statically.composer.json:config.platform.phpis set to 7.4, so the dev install resolves for the plugin's minimum PHP. Neithercomposer.locknorvendor/is committed or deployed.AGENTS.mdcovers:Blast radius
PersonalReply, and the new template IDgk_personal_reply;fluent_crm/email_headers,wp_mail,http_api_debug,gravitysmtp_after_connector_init,gravitysmtp_email_attribute_headers,gravitysmtp_after_mail_updated,fluentcrm_before_subscribers_deleted.Release: none (internal gravitykit.com plugin). No readme.txt or version header bump in this repo.
Tests
php84 vendor/bin/phpunitpasses 296 tests. The full suite also passes on PHP 7.4. Removing each protection fails its test: current run only, the stored quote, the pixel strip, mode restore, Bcc, sent From, the off switch and cleanup batching.Subject: Re: <earlier>,In-Reply-ToandReferences= earlier Message-ID, unencodedReferenceslists both earlier IDsmailmode/Users/zackkatz/Dropbox/MonoKit/reports/pre-mortem-20261204-002557/report.md.id, and the reply threads in Gmail and Apple Mail.Owner for the first week: Zack.
Abilities: none. Internal site plumbing.