Jump to content

Why does the PHP mail() function not work when adding a headers parameter?


obay

Recommended Posts

This works:

 

$to = "[email protected]";
$subject = "CONTACT FORM";
$body = "test";
mail($to, $subject, $body);

 

But when I add an additional parameter $headers, it doesn't work:

 

$to = "[email protected]";
$subject = "CONTACT FORM";
$headers = "From: My Name Here";
$body = "test";
mail($to, $subject, $body, $headers);

 

What could I be doing wrong?

 

Thanks for the help.

Please provide more info. What error are you getting? Is the mail being sent / recieved? Did you check the spam box?

 

Here is a mail function I use. It works like a charm.

 

<?php
                                        $headers ="MIME-Version: 1.0" . "\r\n";
				$headers .= "X-Mailer: PHP/" .phpversion() ."\n";
				$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
				$headers .= 'Return-Path: [email protected]'."\r\n";
				$headers .= "From: YOUR NAME HERE <[email protected]>";
				$address=$email;
				$subject = 'YOUR SUBJECT';
				$body='This is the body of the email';
                                       
                                        mail($address , $subject, $body, $headers);
?>

 

Hope it helps a bit

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.