[請益] 有關網頁phpmail模組錯誤

作者: lusaka (gary.lusifa)   2017-04-03 18:06:35
各位先進你好
目前我在網頁上發先一個問題,就是我們網頁上有一個網頁寄送e-mail的模組,這個模組
是用phpmailer進行發信
這個模組會有選擇我們兩間分店,並將相關資料發送mail,但是現在發生一個問題
是選擇其中一個分店會出現smtp error The Following recipients failed這個問題
我的web server是用apache + my sql網頁連絡人資料是再資料庫中的聯絡人資料表,
寄送的方式是網頁會利用sendmail寄信。想請問各位先進需要怎麼trouble shooting
,因為這個功能在選擇其中一間有問題,另外一間卻是可以的。
請問各位需要從哪邊開始抓問題點。
<?php
//設定
require_once('global.php');
if ($_POST['Mode'] == "Post_Send"){
setcookie("loca",$_POST['loca'], time()+2);
setcookie("Name",$_POST['Name'], time()+2);
setcookie("EMail",$_POST['EMail'], time()+2);
setcookie("Tel",$_POST['Tel'], time()+2);
setcookie("Subject",$_POST['Subject'], time()+2);
setcookie("Content",$_POST['Content'], time()+2);
if (strtolower($_SESSION['AuthCode']) != strtolower($_POST['PostAuthCode'])
|| $_POST['PostAuthCode'] == ""){
ok_msg("Sorry!Img Code error!!","reservation.php");
exit;
}
//寫入各資料名稱
$filed_temp="N_YN";$field_caption[]=$filed_temp;$field_data[]=0;
$filed_temp="N_loca";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['loca']);
$filed_temp="N_Name";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['Name']);
$filed_temp="N_EMail";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['EMail']);
$filed_temp="N_Tel";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['Tel']);
$filed_temp="N_Time";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['Time']);
$filed_temp="N_S1";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['S1']);
$filed_temp="N_S2";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['S2'].$_POST['S3']);
$filed_temp="N_Content";$field_caption[]=$filed_temp;$field_data[]=safesql($_POST['Content']);
$filed_temp="N_IP";$field_caption[]=$filed_temp;$field_data[]=GetIP();
$filed_temp="N_ST";$field_caption[]=$filed_temp;$field_data[]=date("Y-m-d
H:i:s");
//陣列處理資料
foreach ($field_caption as $key => $value){$field_caption[$key] =
"`".$value."`";}
foreach ($field_data as $key => $value){$field_data[$key] =
"'".$value."'";$field_edit[$key]=$field_caption[$key]."=".$field_data[$key];}
//寫入資料庫
$db->query("insert into ".$cfg['TablePrefix']."reservation".$cfg['Lang']."
set ".implode(",",$field_edit)."");
//載入寄信class
require($includespath."class/class.phpmailer.php");
$mail = new phpmailer();
$mail->Mailer = $cfg['phpMailerMethod'];
$mail->Host = $cfg['phpMailerSmtpHost'];
$mail->SMTPAuth = $cfg['phpMailerSMTPAuth'];
$mail->Username = $cfg['phpMailerUsername'];
$mail->Password = $cfg['phpMailerPassword'];
$mail->From = $System['SiteSendMail'.$cfg['Lang']];
$mail->FromName = $System['SiteName'.$cfg['Lang']];
$MailTemp=explode(";",$System['SiteMail'.$cfg['Lang']]);
$eat_place_tmp=$_POST['loca'];
if(preg_match("/高雄店/i",$eat_place_tmp)){
$eat_place=1;
}
else{
$eat_place=2;
}
/*****判斷收信者是誰*******
如果判斷路徑為1,則有#字號的信箱會被切掉#號後寄出,
如果判斷為路徑2,則不切信箱,有#字號的信箱不會收到*/
if($MailTemp[0]) {
for($i=0;$i<count($MailTemp);$i++){
$tmp_l=strlen($MailTemp[$i])-1;
$tmp=strpos($MailTemp[$i],'#');
if($tmp!=false){
if($eat_place==1){
$mailaddress=substr($MailTemp[$i],0,$tmp_l);
$mail->AddAddress($mailaddress);
}
}
else {
if($eat_place==2){
$mail->AddAddress($MailTemp[$i]);
}
}
}
}
else{
$mail->AddAddress($System['SiteMail'.$cfg['Lang']]);
}
作者: kenwufederer (Nash)   2017-04-03 18:14:00
貼程式碼幹嘛?不會貼error log嗎
作者: SeanBoog (施吉祥先生)   2017-04-04 15:09:00
echo一下收件者呀! error都告訴你收件者無法解析了
作者: dou0228 (7777)   2017-04-05 17:22:00
不噓不行
作者: lusaka (gary.lusifa)   2017-04-05 17:58:00
不好意思 已經處理了

Links booklink

Contact Us: admin [ a t ] ucptt.com