2

I am using phpmailer for sending emails, I am attempting to add In-Reply-To in email header but I can't. How can I achieve this? Can I use any message-ID or references when I am sending a email? Is there anything else to add references or In-Reply-To in phpmailer?

So far I have tried to add below line in phpmailer

$mail->AddCustomHeader("In-Reply-To: ")

but it's not working. I also tried to change the return path code like

$mail->ReturnPath = 'bounce_here@domain.com';

but it did not change the return path as well.

And one more things, Can I get the message id by using imap php?

masegaloeh
  • 366
  • 4
  • 12
Mahedi Hasan
  • 178
  • 1
  • 11

1 Answers1

3

Yes, you can fetch the message over IMAP, then extract the headers using imap_headerinfo().

Once you've got the original message ID, you can insert it into your new message.

You need to provide a value to addCustomHeader, not just a name, as the documentation says, like this:

$mail->addCustomHeader('In-Reply-To', $headerinfo['message_id']);

Don't set the return path yourself - that's the job of the message receiver. What you need to set is the Sender property:

$mail->Sender = 'bounce_here@domain.com';
Synchro
  • 35,538
  • 15
  • 81
  • 104