I won't lie. I don't really understand some of the code I have used in the header for this mail function. I have been trying to fix it myself and some of the code is copied from other forum posts etc.
The $email
, $subject
, and $msg
variables are all fine, and emails were sending when I tested them earlier with just these 3 vars. Then I added a header for the "From" section and the sender name was fixed (but emails went into my junk folder - annoying).
Now I am trying to add some html tags to the $msg
and have used the last 2 lines on my $header
variable as per other forum posts, but this has just stopped emails from getting sent at all. Please advise me on how to fix the issue.
$headers = "From: website <donotreply@website.com>" . PHP_EOL .
"BCC: customer1@hotmail.com" . PHP_EOL .
"MIME-Version: 1.0 \r\n" . PHP_EOL .
"Content-Type: text/html; charset=UTF-8' \r\n";
$email = "SomeEmail@hotmail.com";
$subject = "Weekly Newsletter";
mail($email, $subject, $msg, $headers);
Thanks guys I comment section for reminding me to post the error. It says:
Warning: mail(): Multiple or malformed newlines found in additional_header in /path/publishnewsletter.php on line 45