地址无效:[电子邮件受保护],[电子邮件受保护] 邮件程序错误:您必须提供至少一个收件人电子邮件地址。出现错误

问题描述 投票:0回答:1
$thismessage=base64_encode($htmlmsg);  
$subject="Grups Automation siemens and sick sensor Product";
 $mail->SMTPDebug= 2;

            $mail->IsSMTP();                                                //Sets Mailer to send message using SMTP
            $mail->Host = 'My hosting server';      //Sets the SMTP hosts of your Email hosting, this for Godaddy
            $mail->Port = '465';                                //Sets the default SMTP server port
            $mail->SMTPAuth = true;                         //Sets SMTP authentication. Utilizes the Username and Password variables
            $mail->Username = '[email protected]';                  //Sets SMTP username
            $mail->Password = 'secret';                 //Sets SMTP password
            $mail->SMTPSecure = 'ssl';                          //Sets connection prefix. Options are "", "ssl" or "tls"
            $mail->setFrom ('[email protected]','Grups automation');                 //Sets the From email address for the message
            
              $mail->AddAddress($email_id); //Adds a "To" address
      
            $mail->WordWrap = 50;                           //Sets word wrapping on the body of the message to a given number of characters
            $mail->IsHTML(true);
            
            $mail->Subject = $subject;
            $mail->Body = $htmlmsg;
       

if ($mail->Send()) {
    echo 'Mail Sent';
    $sql = 'UPDATE `email_demo` SET `html_sub`="'.$subject.'", `html_body`="'.$thismessage.'",`sending_time`="'.time().'", `status` = "1" ,email_track_code="'. $track_code.'" WHERE `id` = "'.$id.'"';
    if (mysqli_query($con, $sql)) {
        echo 'Database updated successfully';
    } else {
        echo 'Error updating database: ' . mysqli_error($con);
    }
}else{
                echo "Mailer Error: " . $mail->ErrorInfo;
              echo 'There was an error';
       
            }

这是我的代码,它适用于@gmail.com示例:[电子邮件受保护],但相同的代码不适用于特定于域的电子邮件,例如[电子邮件受保护]。以及从数据库获取的电子邮件 ID。

我想要一个解决方案,为什么同样的代码适用于 @gmail.com 而不是其他的。请告诉代码中的问题以及如何解决这个问题

php phpmailer
1个回答
0
投票

尝试从

$mail->AddAddress($email_id);
更改为
$mail->AddAddress($email_id, '');

© www.soinside.com 2019 - 2024. All rights reserved.