Until now there are no problems. The problems start to appear if I want to send an email to the currently logged in user, based on their privilege:
// This section comes right after the first part above
if ($_SESSION['privilege'] < 2) {
$message = '';
} else {
$message = ''; // different HTML message
}
mail($useremail,$subject,$message,$headers);
header('Location: home.php');
Now if I click on the form button, I don’t receive any more emails and the redirect to the homepage fails with a “File not found error”, telling me to check that the filename doesn’t contain uppercase letters or typos and to check if the file was moved, renamed or deleted.
The HTML messages are pretty long and contain information retrieved from a database, therefore it would have been useless to post them here in their entirety.
The to parameter in the mail() function can only accept one email address. You might try adding the extra email addresses into the headers as a CC or BCC field.
That statement is not correct. I regularly use multiple email addresses in the “to” field (separated by commas). The PHP spec also states that multiple recipients are permitted in the “to” field.
Please try this as I use this to send email to several addresses regularly via CRON . You may simply read any html file on your or any server and read and send same as html email.
$headers .= ‘From: Your Name <you@yourdomain.com>’ . "\r
";
$headers .= ‘To: Your Customer Name <yourcustomername@domain.com>, Another Name <anothername@email.com>,
Yet Another Name <anothername1@email.com>, One More Name <onemorename@domain.com>’ . "\r
";
$headers.= ‘Cc: copyto@domain.com’ . "\r
";
$headers.= ‘Bcc: you@yourdomain.com’ . "\r
";