Phpmailer: Reply Using Only "Reply To" Address

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



Leave a reply



Submit