81 lines
2.2 KiB
PHP
81 lines
2.2 KiB
PHP
<?php
|
|
function send_mail($an, $betreff, $text, $ok = '', $error = '') {
|
|
global $absender;
|
|
$sender = 'noreply@troy-grunt.de';
|
|
if(isset($absender) && $absender) {
|
|
$sender = $absender;
|
|
}else{
|
|
include 'secret.php';
|
|
if (isset ( $_sendermail )) {
|
|
$sender = $_sendermail;
|
|
}
|
|
}
|
|
$header = 'From: ' . $sender . "\r\n";
|
|
$header .= 'To: ' . $an . "\r\n";
|
|
$header .= 'Content-Type:text/html' . "\r\n";
|
|
$header .= 'Content-Transfer-Encoding: 8bit' . "\r\n";
|
|
$header .= 'X-Mailer: PHP/' . phpversion ();
|
|
|
|
if (mail ( $an, $betreff, $text, $header ) === true) {
|
|
echo $ok;
|
|
} else {
|
|
echo $error;
|
|
}
|
|
}
|
|
|
|
function send_html_mail($an, $betreff, $text, $ok = '', $error = '') {
|
|
global $absender;
|
|
$sender = 'noreply@troy-grunt.de';
|
|
if(isset($absender) && $absender) {
|
|
$sender = $absender;
|
|
}else{
|
|
include 'secret.php';
|
|
if (isset ( $_sendermail )) {
|
|
$sender = $_sendermail;
|
|
}
|
|
}
|
|
$boundary = md5($an.$betreff.$text.time());
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
function send_php_mail($an, $betreff, $text, $ok = '', $error = '') {
|
|
global $_sendermail;
|
|
$sender = 'noreply@troy-grunt.de';
|
|
if (isset ( $_sendermail )) {
|
|
$sender = $_sendermail;
|
|
}
|
|
include 'php-mailer/PHPMailer.php';
|
|
$mail = new PHPMailer();
|
|
|
|
$mail->setFrom($sender);
|
|
$mail->addAddress($an);
|
|
$mail->Subject = $betreff;
|
|
$mail->msgHTML($text, __DIR__);
|
|
$mail->AltBody = strip_tags($text);
|
|
|
|
if (!$mail->send()) {
|
|
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
|
} else {
|
|
echo 'Message sent!';
|
|
}
|
|
}
|
|
?>
|