Monday 22 January 2018

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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...