phpmailer: Reply using only Reply To address
At least in the current versions of PHPMailers, there's a function clearReplyTos() to empty the reply-to array.
$mail->ClearReplyTos();
$mail->addReplyTo(example@example.com, 'EXAMPLE');
Setting replyTo field in email
Try:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2@example.com
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1@example.com
$this->phpmailer->Subject = $subject;
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Try setting AddReplyTo() first before SetFrom. phpmailer needs to change this behavior. It adds the from address to the reply-to field. If you set reply-to first before the from address, it will not be able to add your from address to the reply-to header.
Replying to an email with PHPmailer
It's quite reasonable to have every message in a thread using a different subject line, so threading is only dependent on the subject line as a last-resort fallback if you're doing everything else wrong. It's actually quite annoying when clients do this as you end up with unrelated messages that happen to have the same subject grouped together.
Threading and replies are implemented using the References
and In-Reply-To
headers as defined in RFC2822. Read this guide for a thorough description of how to do threading reliably.
The short version is this, for the first reply to a message:
$mail->addCustomHeader('In-Reply-To', $message_id);
$mail->addCustomHeader('References', $message_id);
It gets more complex if the original message is just the latest in a long thread, but it uses the same headers - read the spec and the guide for more info.
Make sure your message ID is correctly formatted - it should be surrounded by <>
, like <d7751ea969c01cda464ebf2de2fe64e6@example.org>
.
You don't need to do anything to the subject line - though it's common to prepend Re:
, it's not necessary for the linkage to work, and it also varies across languages, so it's not something you can rely on.
PHPMailer: How to make reply to all CC automatic
You can't. That's not what CC is for. What you can do is put multiple addresses in Reply-To. In PHPMailer you'd do that like this:
$mail->addReplyTo('address1@example.com', 'User One');
$mail->addReplyTo('address2@example.com', 'User Two');
When the user replies to that, the reply will be sent to both addresses.
Related Topics
Error: MySQLnd Cannot Connect to MySQL 4.1+ Using the Old Insecure Authentication
Regex/ Code to Fix Corrupt Serialized PHP Data
Automatically Detect User's Current Local Time with JavaScript or PHP
Get the First or Last Friday in a Month
Using Value of a Column as Index in Results Using Pdo
Get Repeated Matches with Preg_Match_All()
Rest API Authorization & Authentication (Web + Mobile)
Multiple Excerpt Lengths in Wordpress
How to Downgrade or Install a Specific Version of Composer
How to Use Multi Auth in Laravel 5.2
How to Create a Twig Custom Tag That Executes a Callback
How to Cast Array Elements to Strings in PHP
Search and Replace Multiple Values with Multiple/Different Values in PHP5
Malformed Utf-8 Characters, Possibly Incorrectly Encoded' in Laravel