$subject = get_the_title();
$sender_name = get_bloginfo('name');
$blog_url = get_bloginfo('url');
$to = 'myemail@mydomainname.com';
$subject="the subject";
$message="hello";
$headers="MIME-Version: 1.0" . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$sender_name.' <no-reply@'.$blog_url.'>' . "\r\n";
$headersssssssssssss="From: webmaster@example.com" . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
When I use the $headersssssssssssss
variable as a parameter in the mail()
function, it works and sends an E-Mail.
But when I use $headers
as a parameter, it does not.
Note: I have already tried using wp_mail
instead, with the same results.
if( mail($to, $subject, $message, $headersssssssssssss) )
{
echo '<script>alert("mail sent success!");</script>';
} else {
echo '<script>alert("mail where not sent");</script>';
}
exit;