請問有邦友也遇過PHPMailer同一封信會寄兩次的情形嗎? code也都和之前的寫法大同小異, mail主機的設定應該是沒問題 實在看不出來出了什麼問題
require("PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->CharSet = "utf-8";
$mail->Encoding = "base64";
$mail->FromName = "仙山仙草訂單資訊"; //寄件者姓名
$mail->Host = "localhost"; //mail server
$mail->Subject = '仙山仙草訂單資訊'; //信件標題
$mail->From = 'service@host.com.tw'; //設定寄件者信箱
$mail->Body = $Message3;
$mail->IsHTML(true);
$mail->AddAddress("receiver@gmail.com"); //收件者郵件及名稱
$mail->SMTPAuth = false;
$mail->SMTPDebug = 2;
$mail->Send();
請參考看看
require(__DIR__ ."./PHPMailer/src/PHPMailer.php");
require(__DIR__ ."./PHPMailer/src/Exception.php");
require(__DIR__ ."./PHPMailer/src/SMTP.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.server'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mail信箱'; // SMTP username
$mail->Password = '信箱密碼'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
//$mail->Port = 587; // TCP port to connect to
//$mail->mb_internal_encoding('UTF-8');
//Recipients
$mail->setFrom('寄件者信箱', '系統管理者');
$mail->addAddress($收件者); // Name is optional
$mail->addReplyTo('副本', 'Information');
// Attachments
//$mail->addAttachment('路徑'); // Add attachments
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject =$主旨;
$mail->Body = $內容;
$mail->send();