Помогите пофиксить ошибку, вот код отправки письма.
function smail($ml,$ma,$dat){
global $db;
$area = substr(SITE_NAME,0,3);
$msubj = "=?utf-8?b?".base64_encode($ma[2])."?=";
$mfrom = "=?utf-8?b?".base64_encode($ma[3])."?= <".$ma[4].">";
$mbd = $ma[5];
$mfls = explode("^",$ma[6]);
$ifls = explode("|",$mfls[0]);
$afls = explode("|",$mfls[1]);
$ift = count($ifls);
$aft = count($afls);
$body = '';
if($mfls[0] != "" || $mfls[1] != ""){
$bound = "mysite.ru-2018";
$bound1 = "mysite.ru-2018-1";
}
$header = "From: ".$mfrom."\n";
$header .= "X-Mailer: IMail\r\n";
$header .= "X-Priority: 3 (Normal)\n";
$header .= "Mime-Version: 1.0\n";
if($mfls[1] != "" ){ $header .= "Content-Type: multipart/mixed;"; /* txt - imgs - attach */ echo '$mfls[1]<br/>'; }
if($mfls[0] != "" ){ $header .= "Content-Type: multipart/alternative;"; /* txt - imgs */ }
if($mfls[0] != "" || $mfls[1] != ""){ $header .= " boundary=\"".$bound."\"\n\n"; }
if($mfls[0] == "" || $mfls[1] == ""){ $header .= "Content-type: text/html; charset=\"utf-8\"\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n"; /* txt - html */ }
if($mfls[0] != "" || $mfls[1] != ""){
$body .= "--".$bound."\n";
$body .= "Content-type: multipart/related;\n";
$body .= " boundary=\"".$bound1."\"\n";
$body .= "--".$bound1."\n";
}
if($mfls[0] != "" || $mfls[1] != ""){
$body .= "Content-type: text/html; charset=\"utf-8\"\n";
$body .= "Content-Transfer-Encoding: 8bit\n\n";
}
$body .= $mbd."\n";
if($mfls[0] != "" ){
foreach($ifls as $fl){
$ifl = "http://".$area.".mysite.ru/index.php?token=".SITE_TOKEN."&act=file&mid=".$ma[0]."&in=".$fl;
$ctype = substr($fl,-3);
$file = file_get_contents($ifl);
$body .= "--".$bound1."\n";
$body .= "Content-Type: image/".$ctype."; name=\"".$fl."\"\n";
$body .= "Content-Disposition: inline\n";
$body .= "Content-Transfer-Encoding:base64\n";
$body .= "Content-ID:<".$fl.">\n\n";
$body .= base64_encode($file)."\n";
}
}
if($mfls[0] != "" || $mfls[1] != ""){
$body .= "--".$bound1."--\n\n";
}
if($mfls[1] != ""){
foreach($afls as $fl){
$ifl = "http://".$area.".mysite.ru/index.php?token=".SITE_TOKEN."&act=file&mid=".$ma[0]."&in=".$fl;
$ctype = substr($fl,-3);
$file = file_get_contents($ifl);
$body .= "--".$bound."\n";
$body .= "Content-Type: image/".$ctype."; name=\"".$fl."\"\n";
$body .= "Content-Transfer-Encoding:base64\n";
$body .= "Content-Disposition:attachment; filename=\"".$fl."\"\n\n";
$body .= chunk_split(base64_encode($file))."\n";
}
}
if($mfls[0] != "" || $mfls[1] != ""){
$body .= "--".$bound."--";
}
$i = 0;
$tm = count($ml);
while ($i<$tm){
$ma = explode("|",$ml[$i]);
if(mail($ma[1],$msubj,$body,$header)){
$cl = mysql_query("SELECT * FROM mail_lists WHERE lid='".$dat[3]."'");
$rcl = mysql_fetch_row($cl);
//$mlist = mysql_query("SELECT * FROM ".$rcl[1]." WHERE status IS NULL LIMIT ".EM_MAX);
$res = mysql_query("UPDATE ".$rcl[1]." SET status=1 WHERE umid='".$ma[0]."'");
if($res == 'true'){ sleep(EM_TIME); }
}else{
$res = mysql_query("UPDATE mail_tab SET status=0 WHERE umid='".$ma[0]."'");
if($res == 'true'){ }
}
$i++;
}
}
Багует строчка
if($mfls[0] != "" || $mfls[1] != ""){ $header .= " boundary=\"".$bound."\"\n\n"; }
Если урать \n\n из boundary, вот так
$header .= " boundary=\"".$bound."\"";
То ошибка исчезает, письмо отправляется, но в письме файл в двоичном виде текстом в письме. Как это пофиксить?
Виртуальный выделенный сервер (VDS) становится отличным выбором
Столкнулся с вот такой проблемойСоздал небольшую форму с обработчиком