Search code examples
phpemailphpmailerreplayreturn-path

Forwarded email replay with phpmailer


Normally when we send a reply email we just add "Re:" in email subject but when a email come from any other forwarded email then how can I reply to this email?

Example:

an email is sent from [email protected], forwarded from [email protected], and received at email address [email protected]. Now when I send a reply from [email protected] to the sender [email protected] what should I do?

I tried using "Re:" in subject but it not act as reply email. Please help me.


Solution

  • Whether an email is treated as a reply is not dependent on the subject line. A message that is a reply will have an In-Reply-To and/or References headers containing the message id(s) of the messages it is a reply to or forward of. This is defined in RFC5322 section 3.6.4. When replying to a message, you need to extract the message ID from the original message and insert it in the references header, preserving any existing entries in there. You can set this in PHPMailer using the addCustomHeader() method.

    As far as I'm aware, there is no internal distinction between a reply and a forward - both will add to the references header - the only usual difference is who they are sent to, and often by adding a prefix to the subject line (often re: or fw:, but it varies between languages), but note that this is purely cosmetic and informational - it does not alter the behaviour of the message nor how it is linked to other messages.