Skip to content

Save sent emails to IMAP Sent folder#1003

Open
chubes4 wants to merge 2 commits intomainfrom
fix/email-save-to-sent
Open

Save sent emails to IMAP Sent folder#1003
chubes4 wants to merge 2 commits intomainfrom
fix/email-save-to-sent

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Mar 31, 2026

Problem

When sending or replying via wp datamachine email reply, the message is sent through SMTP (Easy WP SMTP / Amazon SES) but no copy is saved to the sender's email client. The email doesn't appear in Gmail's Sent Mail or the conversation thread on the sender's side.

Fix

After a successful wp_mail() call in executeReply(), append the sent message to the IMAP Sent folder via imap_append(). This makes the reply show up in Gmail's "Sent Mail" and thread view.

  • Tries [Gmail]/Sent Mail first (Gmail's folder name)
  • Falls back to Sent, Sent Items, INBOX.Sent for non-Gmail servers
  • Best-effort: if IMAP append fails, the send still succeeds — no error thrown
  • Message is marked as \Seen so it doesn't show as unread

Context

Discovered when replying to a partnership inquiry via CLI — the reply was delivered to the recipient but didn't appear in the sender's Gmail thread, making it invisible to the account owner.

chubes4 added 2 commits March 31, 2026 04:39
applyStepConfigsToFlow() only accepted singular handler_slug and
handler_config keys, but the CLI and admin UI pass the plural forms
handler_slugs (array) and handler_configs (keyed object).

Now handles both:
- handler_slugs: iterates and calls add_handler for each slug with
  its matching config from handler_configs
- handler_slug/handler_config: still works as before (backward compat)

This means flows create --step_configs with handler_slugs and
handler_configs now works in a single command.
When replying via the email CLI, wp_mail() sends through SMTP but
doesn't save a copy to the sender's email client. This adds an
imap_append() call after successful send to copy the message to
[Gmail]/Sent Mail (with fallbacks for non-Gmail servers).

Best-effort: if the IMAP append fails, the send still succeeds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant