1

So, I don't know how to explain properly, but here is the current situation.

Let say the site is called "Demo.com" and site admin email is "[email protected]"

Then,

  1. An author(example, [email protected]) posts a post.
  2. a visitor (another user, [email protected]) leaves a comment or reply on the post.
  3. the author(user-X) gets an email notification.

Here is the thing.

The email sender is the admin "[email protected]" and not the visitor.

Thus, when the author tries to reply back directly from the email, he is replying back to the "[email protected]" and not "[email protected]".

How can I change it so that the reply can be sent to the original viewer (user-y)?

Any suggestions?

2 Answers 2

1

What you need to do is to modify the code that sends the email to the author and in it set the "reply-to" header of the email, pass it as part of the headers parameters to wp-mail.

Your code should be something like (adapted from the php mail function documentation).

$to      = '[email protected]';
$subject = 'new comment';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]';

wp_mail($to, $subject, $message, $headers);

Of course you will need to get the relevant email addresses from the post author and the comment author fields, and you will probably want to specify the "nice names" of all the people involved with the actual email address

1
  • Thank you for the reply. I will give that a try and post what I did to make it work (when it works). Thanks!
    – Steve Kim
    Mar 27, 2015 at 4:23
0

you could use this filter: comment_notification_headers

for reference:

https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/pluggable.php#L1434

line: 1434 and 1471

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.