fix contact email encoding

This commit is contained in:
Martin Stadler
2019-06-24 14:57:51 +02:00
parent 312857d213
commit f24ea0007b
+14 -6
View File
@@ -7,7 +7,7 @@ class Contact_Mail extends Message {
private $to = 'Martin Stadler <martin@siarp.de>, Tilman Walther <tilman@tilman.de>';
private $subject = 'Post für Beethoven2000';
private $from = 'From: Beethoven2000 Kontaktformular <abi@beethoven2000.de>';
private $from = 'Beethoven2000 Kontaktformular <abi@beethoven2000.de>';
/**
* Sendet die Mail mit den Übergebenen Parametern.
@@ -25,16 +25,24 @@ class Contact_Mail extends Message {
$this->spam = true;
return true;
}
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$header .= 'From: ' . $this->from . "\r\n";
$contents = 'Name: ' . $name . "\n";
$contents .= 'eMail: ' . $address . "\n";
$contents .= "\n--------\n";
$contents .= utf8_decode(preg_replace('~\r~', '', $message));
$contents = 'Name: ' . $name . "\r\n";
$contents .= 'eMail: ' . $address . "\r\n";
$contents .= "\r\n--------\r\n";
$contents .= $message;
if (!mail($this->to, $this->subject, $contents, $this->from)) {
if (!mail($this->to, $this->encode($this->subject), $contents, $header)) {
$this->error = true;
}
}
private function encode ($text) {
return '=?UTF-8?B?' . base64_encode($text) . '?=';
}
}
?>