iT邦幫忙

0

PHPMailer發信時會收到兩封同樣的信

  • 分享至 

  • xImage

請問有邦友也遇過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();    
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
mayyola
iT邦研究生 1 級 ‧ 2020-08-22 10:04:53

請參考看看

  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();

我要發表回答

立即登入回答