PHP-beginner here trying to solve a problem for literally days now:
I'm trying to send html-mails with the PHP mail() function via the IONOS Mailserver. Html is important because I want to set the encoding for the e-mails in the header (special characters).
Somehow the script that I'm successfully using on other providers' servers isn't working on the IONOS servers. According to IONOS-support the e-mails weren't following the RFC5321 and RFC5322 standards.
I have been told to change my script and that the following field-types are required as a part of header: "Date:", "From:", "Sender:" and "To:" and these field-types must not be included more than once: "Date:", "From:", "Sender:", "To:", "CC:", "BCC:", "Subject:". Furthermore the field-type "Date:" has to be valid and following the RFC2822 standard.
Here is what I came up with:
$datum = date(DateTime::RFC2822);
$empfaenger = "info@xyz.de";
$headers = array();
$headers[] = "Date: {$datum}";
$headers[] = "From: {$email}";
$headers[] = "Sender: {$email}";
$headers[] = "To: {$empfaenger}";
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=utf-8";
$headers[] = "X-Mailer: PHP/".phpversion();
mail("$empfaenger","Kontaktaufnahme via www.xyz.de von $name $vorname",$mailbody,implode("\r\n",$headers));
The variables missing here are defined earlier on.
Unfortunately this won't send the Mails via the IONOS-mailserver either.
Can anyone point out where I'm making the mistake? Thank you very much in advance!