better html emails

This commit is contained in:
troy 2022-11-11 13:20:20 +01:00
parent 6e7fd28762
commit 0b7d47e816

View File

@ -18,3 +18,32 @@ function send_mail($an, $betreff, $text, $ok = '', $error = '') {
}
}
function send_html_mail($an, $betreff, $text, $ok = '', $error = '') {
$boundary = md5($an.$betreff.$text.time());
include 'secret.php';
$sender = 'noreply@troy-grunt.de';
if (isset ( $_sendermail )) {
$sender = $_sendermail;
}
$header = 'From: ' . $sender . "\n";
$header .= 'To: ' . $an . "\n";
$header .= 'Content-Type:multipart/alternative;boundary='.$boundary . "\n";
$header .= 'X-Mailer: PHP/' . phpversion ();
$content = "This is multipart message using MIME\n";
$content .= "--" . $boundary . "\n";
$content .= "Content-type: text/plain;charset=utf-8\n";
$content .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
$content .= strip_tags($text)."\n\n";
$content .= "--" . $boundary . "\n";
$content .= "Content-type: text/html;charset=utf-8\n";
$content .= "Content-Transfer-Encoding: 8bit". "\n\n";
$content .= '<html><body>'.$text.'</body></html>'."\n\n";
if (mail ( $an, $betreff, $content, $header ) === true) {
echo $ok;
} else {
echo $error;
}
}
?>