WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a theme that has a built in contact form, which has some options (like where the form is sent) set through the OptionTree plugin.

What's happening is, the email gets sent, but the reply-to is a made-up server address at the webhost, rather than what the visitor's self-stated email is. This is really weird.

When I look at the code, it all seems sound:

//If there is no error, send the email
if(!isset($hasError)) {
    $emailTo = get_option_tree( 'contact_page_email' );  /*Put your own email address here*/ 
    $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
    $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;

It looks like the code is supposed to set reply-to to be the person's stated email address. But our mail server, for some reason, wants to set the reply for all form responses to a server-generated address. The reply-to address ends up being clientaccount@s4-vancouver.accountservergroup.com.

Does anyone have any ideas why this might be happening? The code looks sound to me -- I just can't figure out why when we receive mail from the server from the contact form, it appears to come from an address that isn't the client's email.



share|improve this question
Always use wp_mail(), not mail(). – toscho Jan 12 '13 at 7:48
If you echo/var_dump the $headers what do you get? I – Mark Kaplun Jan 12 '13 at 12:14
Hey all, thanks for responding. Toscho, I've tried to replace the mail function with wp_mail. Even if it's the right thing to do, it doesn't seem to have any effect on the apparent sender. Here's my new code: if(!isset($hasError)) { $message = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; $headers = 'From: Wordpress <wordpress@mysite.ca>' . "\r\n"; wp_mail('web@mysite.ca', 'Contact from our website form', $message, $headers, $attachments); $emailSent = true; } – Rob Butz Jan 13 '13 at 1:31
Mark, I'm not sure where I'd get to see the dump of the $headers. Console? Somewhere else? The form uses an AJAX submission so that you stay on the same page and erases the form as soon as you send. – Rob Butz Jan 13 '13 at 1:33

Try this format: Reply-To: John Doe<john@example.com>.

Ref: http://blackwidows.co.uk/blog/2006/10/02/reply-to-header-can-create-bounces/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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