# *** mail function to resolve the "Return-Path:" header problem & format the mail header function send_mail($to_mail, $to_name, $from_mail, $from_name, $mail_subject, $mail_content, $mail_prio, $error_mail, $error_name, $attachment = "") { global $site_statics; # set mailformat if (!$site_statics["mail_format"] || $site_statics["mail_format"] == "text") { # $mail_content=cut_html($mail_content); $mail_typ = "Content-type: text/plainnContent-Transfer-Encoding: 7bit"; }
if ($site_statics["mail_format"] == "html") { $mail_content = (stristr($mail_content, "")?$mail_content:"" . $mail_content . ""); $mail_typ = "Content-type: text/html; charset=iso-8859-1nContent-Transfer-Encoding: 8bit"; }
if (!empty($attachment)) $mail_typ = $attachment;
if ($to_name) $to_name = $to_name . " "; # change the "Return-Path:" only for registered user !!! if (!$error_mail) $error_mail = $site_statics["webmaster"]; if (!$error_name) $error_name = $site_statics["webname"];
$to_name = imap_mime_header_encode($to_name, "iso-8859-1"); $from_name = imap_mime_header_encode($from_name, "iso-8859-1"); $error_name = imap_mime_header_encode($error_name, "iso-8859-1"); if ($site_statics["mail_format"] != "sms") $mail_subject = imap_mime_header_encode($mail_subject, "iso-8859-1"); # set "T" format if ($site_statics["win_system"] == "no") $send_to = $to_name . "<" . $to_mail . ">"; else $send_to = $to_mail; # set mail priority if (!$mail_prio || $mail_prio == "norm") { $xp = "3"; $mp = "Normal"; } else { $xp = "1"; $mp = "High"; } # set the headers $mail_head .= "From: " . $from_name . " <" . $from_mail . ">n"; # Absender $mail_head .= "Sender: " . $from_name . " <" . $from_mail . ">n"; # Absender for Outlook (Return-Path: überschreibt From:) $mail_head .= "Reply-T " . $from_name . " <" . $from_mail . ">n"; # automatische Antwortadresse $mail_head .= "Errors-T " . $error_name . " <" . $error_mail . ">n"; # error return adress $mail_head .= "Bounce-T " . $error_name . " <" . $error_mail . ">n"; # error return adress $mail_head .= "Return-path: " . $error_name . " <" . $error_mail . ">n"; # error return adress $mail_head .= "X-Sender: " . $error_name . " <" . $error_mail . ">n"; $mail_head .= "X-Priority: " . $xp . "n"; # 1 - wichtig 3 - normal $mail_head .= "X-MSMail-Priority: " . $mp . "n"; # Normal,High for Outlook $mail_head .= "Importance: " . $mp . "n"; # Normal,High $mail_head .= $mail_typ . "n"; # text/html; charset=iso-8859-1n # Mime Type HTML if ($site_statics["mail_format"] != "sms") $mail_head .= "X-Mailer: PHP/" . $error_name; # Mailprogramm # get php version $php_version = phpversion(); # the "Return-Path:" header (eg. if "T" doesn't exist) doesn't work, but since PHP v4.0.5 # mail() function has a new parameter for sendmail commandline parameters if (ereg("[4-9].[0-9].[5-9].*", $php_version) || ereg("[4-9].[1-9].[0-9].*", $php_version)) $new_mail = true; else unset($new_mail); if ($new_mail) { # set "Return-Path:" error return adress # set "T" format if ($site_statics["win_system"] == "no") $mail_return = "-f" . $error_name . "<" . $error_mail . ">"; else $mail_return = "-f" . $error_mail; $respond = mail($send_to, $mail_subject, $mail_content, $mail_head, $mail_return); } else { $respond = mail($send_to, $mail_subject, $mail_content, $mail_head); } if ($respond) return true; else return false; }
|