#
#
#
$DEBUG=0;
#
#
#
if ($DEBUG){
echo "email_neu.php
\n";
}
include_once("auth.php");
include_once( "../include/class.SQLString.php" );
include_once( "../include/class.SQLInteger.php" );
include("email_functions.php");
include("email_config.php");
include("email_header.php");
$partscount =0;
if($forwardid && e_connect()){
$structure = imap_fetchstructure($mbox, $forwardid);
$structarr = headerArray($structure);
$partscount = sizeof($structure->parts);
}
if($sendmail) {
?>
|
/* This ContentTypes should not be encoded with base64 - use the given encode-Type e.g. "8bit" */
$encodeType["text/plain"] = "8bit";
$encodeType["text/html"] = "8bit";
$encodeType["message/rfc822"] = "8bit";
$encodeType["message/external-body"] = "8bit";
$encodeType["message/http"] = "8bit";
$encodeType["message/news"] = "8bit";
$encodeType["message/partial"] = "8bit";
if($from != "" && $to != "") {
$to = str_replace ("\\", "", $to);
$to = str_replace (";", ",", $to);
$cc = str_replace ("\\", "", $cc);
$cc = str_replace (";", ",", $cc);
$bcc = str_replace ("\\", "", $bcc);
$bcc = str_replace (";", ",", $bcc);
if($signatur) {
$query_sign = safe_query( "SELECT * FROM $cnf_db_sign WHERE alias = ?", TRUE, new SQLString($from) );
$sign = db_fetch_array($query_sign);
$content = $content."\n".$sign['signatur'];
}
#
# To exclude superfluous blank lines
#
$mail_content='';
$lines=explode("\n",$content);
foreach ($lines as $line){
$mail_content.=wordwrap(rtrim($line),72,"\n")."\n";
}
if(preg_match("/\n\n$/",$mail_content)){ // there are last blank lines
$lines=explode("\n",$mail_content);
while(!($line = array_pop($lines)) && (count($lines)>0)){
/* pop blank lines*/
}
array_push($lines,$line);
$mail_content=implode("\n",$lines);
}
#
# end to exclude superfluous blank lines
#
$mail_header = "From: $from";
switch($priority) {
case "1":
$mail_header .= "\nX-Priority: 1\nImportance: High\nX-MSMail-Priority: High";
break;
case "3":
$mail_header .= "\nX-Priority: 3\nImportance: Normal\nX-MSMail-Priority: Normal";
break;
case "5":
$mail_header .= "\nX-Priority: 5\nImportance: Low\nX-MSMail-Priority: Low";
break;
}
if($priority){
$mail_header .= "\nX-MimeOLE: Produced by Confixx WebMail".
"\nX-Mailer: Confixx WebMail (like SquirrelMail)";
/* need for spamassassin */
}
$mail_header .= "\nCc: $cc";
$mail_header .= "\nBcc: $bcc";
if($DEBUG){
echo "attachment_name: $attachment_name \n"; } $mail_attach=''; $boundary = strtoupper(md5(uniqid(time()))); # # forward attachment # for($i=0; $i<=$partscount; $i++){ if ($attachs[$i]){ if ($DEBUG){ echo "$i: ".$attachs[$i]." \n"; } $part=$structure->parts[$i]; if (is_object($part)){ $ha = headerArray($part); $fn = ''; if($ha["dparameters"]["filename"]){ $fn = $ha["dparameters"]["filename"]; } if($ha["parameters"]["name"]){ $fn = $ha["parameters"]["name"]; } if(!$fn){ $fn = $lang_text["wbm_unknown"]; } if ($fn==$attachs[$i]){ if ($body = imap_fetchbody($mbox, $forwardid, ($i+1))){ $hdrs = "\n--$boundary"; $hdrs .= "\nContent-Type: ".$ha["type"]."; name=\"$fn\""; $hdrs .= "\nContent-Transfer-Encoding: ".$ha["encoding"]; $hdrs .= "\nContent-Disposition: attachment; filename=\"$fn\""; $hdrs .= "\n\n"; if ($DEBUG){ print_r($ha); echo " \n$i: \n $hrds \n"; } $mail_attach.=$hdrs; $mail_attach.=$body; } } } } } if($attachment_name != "") { if ($fh=fopen($attachment,"r")){ $attach_content = fread($fh,filesize($attachment)); fclose($fh); } if($encodeType["$attachment_type"]) { $encode = $encodeType["$attachment_type"]; } else { $encode = "base64"; $attach_content = chunk_split(base64_encode($attach_content)); } $mail_attach .= "\n--$boundary"; $mail_attach .= "\nContent-Type: $attachment_type; name=\"$attachment_name\""; $mail_attach .= "\nContent-Transfer-Encoding: $encode"; $mail_attach .= "\nContent-Disposition: attachment; filename=\"$attachment_name\""; $mail_attach .= "\n\n$attach_content"; } if(!$mail_attach){ $mail_header .= "\nContent-Type: text/plain"; $mail_header .= "\nContent-Transfer-Encoding: 8bit"; $mail_header .= "\n$mail_content"; } else { $mail_header .= "\nMIME-Version: 1.0"; $mail_header .= "\nContent-Type: multipart/mixed; boundary=$boundary"; $mail_header .= "\n\nThis is a multi-part message in MIME format -- Dies ist eine mehrteilige Nachricht im MIME-Format"; $mail_header .= "\n--$boundary"; $mail_header .= "\nContent-Type: text/plain"; $mail_header .= "\nContent-Transfer-Encoding: 8bit"; $mail_header .= "\n\n$mail_content"; /* Attachment */ $mail_header .=$mail_attach; $mail_header .= "\n--$boundary--"; } /* Send email */ $sendmail_ok = $lang_text["wbm_sendmail_ok"]; $sendmail_ok = str_replace("%subject%",""$subject"",$sendmail_ok); $to2 = str_replace("<","&",$to); $to2 = str_replace(">","&",$to2); $sendmail_ok = str_replace("%to%","$to2",$sendmail_ok); if ($DEBUG){ echo "message: \n $mail_header \n"; } # # send mail # if(@mail($to,$subject,"",$mail_header)) { echo $sendmail_ok; } else{ echo "".$lang_text["wbm_sendmail_error"].""; } echo " "; echo str_replace("\n"," ",(htmlspecialchars($mail_content))); } else { echo $lang_text["wbm_sendmail_norecipient"]; } ?> |
| echo std_button(ltext("wbm_buttonnext"), 'email_postfach.php'); ?> |