Friday, 19 February 2016

PHP mail() function not sending email

I am attempting to send an email using the mail() PHP function. I had it working until I attempted to give it a subject of "User registration", then the mail is not sent!



Heres the code (have simplified it greatly)




$to = $this->post_data['register-email'];
$message = 'Hello etc';
$headers = 'From: noreply@example.com' . "\r\n" ;
$headers .= 'Content-type: text/html; chareset=iso-8859-1\r\n';
$headers .= 'From: Website ';
mail($to, 'User Registration', $message, $headers);


I also attempted to use a variable containing the string of text but that didnt work.




Why is it not sending the mail when I add the subject exception?



Thanks



EDIT: updated code thats still not working



$to = $this->post_data['register-email'];
$message = 'Hello etc';


$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: Website ';
mail($to, 'User Registration', $message, $headers);

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...