Rafiq
Rafiq

Reputation: 1

Emails aren't sent in Wordpress with headers

I'm running a new WordPress website on LEMP on Debian 7, sendmail installed.

I have a custom theme installed which has contact form.

Contact form says email sent but email actually not delivered. I have tried to remove $headers from email, email delivered. Simple php mail function working properly. Same custom theme sending and delivering email through form at Shared host.

Here is part of custom form:

What is wrong with this? can anyone point me out what is wrong or how I can start sending emails?

if(!isset($hasError) && ($correct == true)) {

    $admin = get_bloginfo('admin_email');
    $portfolio = get_bloginfo('name');
    $portfolio_url = home_url();

    $emailTo = $admin;
    $pro = get_the_title();
    $subject = "You have an message for $pro";
    $body = "Hello,\r\n\r\nYou've received an message from ".$name.", for ".$pro." fun name.\r\n\r\nHere are message details:\r\n--------------------------------\r\nBuyer Name: ".$name."\r\nEmail: ".$email."\r\nMessage: ".$message." ".$CurrencyCode."\r\n\r\nMessage: ".$message."\r\n\r\n---------\r\n".$portfolio."\r\n".$portfolio_url;
    $headers = "From: ".$portfolio." <".$emailTo.">" . "\r\n" . "Reply-To: " . $email;

    wp_mail($emailTo, $subject, $body, $headers);

    $emailSent = true;
}

Thank you!

Upvotes: 0

Views: 168

Answers (1)

taxicala
taxicala

Reputation: 21759

wp_mail has an open bug related to the Reply-To header. Try removing that header only and check if the email is sent correctly. If that's the case, you will have to create a plugin to wrap it or just avoid setting the Reply-To header.

Upvotes: 1

Related Questions