亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何解決服務器 filezilla 上的聯系表單(phpmailer)上的錯誤?

如何解決服務器 filezilla 上的聯系表單(phpmailer)上的錯誤?

PHP
慕斯709654 2022-01-08 16:55:36
我正在使用 PHPmailer 作為我的聯系表,當我用 XAMPP 打開我的網站時它可以工作,但是當我將網站上傳到在線服務器(filezilla)時,聯系表顯示錯誤。use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;require 'vendor/autoload.php';$error = '';$name = '';$email = '';$subject = '';$message = '';function clean_text($string){ $string = trim($string); $string = stripslashes($string); $string = htmlspecialchars($string); return $string;}if(isset($_POST["submit"])){ if(empty($_POST["name"])) {  $error .= '<p><label class="text-danger">*Por Favor Insira o seu Nome</label></p>'; } else {  $name = clean_text($_POST["name"]);  if(!preg_match("/^[a-zA-Z ]*$/",$name))  {   $error .= '<p><label class="text-danger">Apenas letras e espa?os em branco sao permitidos</label></p>';  } } if(empty($_POST["email"])) {  $error .= '<p><label class="text-danger">*Por Favor Insira o seu Email</label></p>'; } else {  $email = clean_text($_POST["email"]);  if(!filter_var($email, FILTER_VALIDATE_EMAIL))  {   $error .= '<p><label class="text-danger">Formato de email inválido</label></p>';  } } if(empty($_POST["subject"])) {  $error .= '<p><label class="text-danger">*Por Favor Insira o seu Assunto</label></p>'; } else {  $subject = clean_text($_POST["subject"]); } if(empty($_POST["message"])) {  $error .= '<p><label class="text-danger">Por Favor Insira a sua Mensagem</label></p>'; }顯示錯誤:致命錯誤:未捕獲的 PHPMailer\PHPMailer\Exception:SMTP 連接()失敗。https://github.com/PHPMailer/PHPMailer/wiki//home1/carvalho/public_html/vendor/phpmailer/phpmailer/src/PHPMailer.php:1775中的疑難解答:#0 /home1/carvalho/public_html/vendor/ phpmailer/phpmailer/src/PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->smtpSend('Date: Thu, 12 S...', '\r\n\r\n ...') #1 /home1/carvalho/public_html/vendor/phpmailer/phpmailer/src/PHPMailer.php(1352): PHPMailer\PHPMailer\PHPMailer->postSend() #2 /home1/carvalho/public_html/contact2.php(119): PHPMailer\ PHPMailer\PHPMailer->send() #3 {main} 在第 1775 行的 /home1/carvalho/public_html/vendor/phpmailer/phpmailer/src/PHPMailer.php 中拋出
查看完整描述

2 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

如果您確定憑據正確,請檢查 PORT 和 SMTP 安全,因為:端口 25 不需要 ssl / tls 支持端口 465 用于 ssl 端口 587 用于 tls


像這樣修復您的代碼:


$mail = new PHPMailer(true);

$mail->CharSet = "UTF-8";


$mail->IsSMTP();        


$mail->Host = 'smtp.sapo.pt';  

$mail->Port = 587; // this for "tls" connection  

$mail->SMTPAuth = true;      

$mail->Username = '[email protected]';


$mail->Password = '*****';  


$mail->SMTPSecure = 'tls'; // this require 587    

$mail->From = $_POST["email"];    

$mail->FromName = $_POST["name"];   

$mail->addAddress('[email protected] ', 'namecompany');


$mail->WordWrap = 50;       

$mail->IsHTML(true);          

$mail->Subject = $_POST["subject"];


查看完整回答
反對 回復 2022-01-08
?
白衣非少年

TA貢獻1155條經驗 獲得超0個贊

您的 SMTP 憑據在生產服務器上不同。您只需要獲得有效的憑據


查看完整回答
反對 回復 2022-01-08
  • 2 回答
  • 0 關注
  • 167 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號