简体   繁体   English

PHPMailer 无法在 Godaddy 服务器上运行

[英]PHPMailer is not working on godaddy server

I have developed a site in PHP and added a PHPMailer function for my contact us page but the mailer functionality is not working.我已经用 PHP 开发了一个站点,并为我的联系我们页面添加了一个 PHPMailer 函数,但是邮件程序功能不起作用。 Contacted with support team but they didn't help me tried a lot with that.与支持团队联系,但他们没有帮助我尝试了很多。

<?php
    if(isset($_POST['submit_contact']))  
    {
       require 'PHPMailer/PHPMailerAutoload.php';
       $to = "gmail@gmail.com";
       $name = $_POST['uname'];
       $email = $_POST['email'];
       $phone = $_POST['phonenumber'];
       $companyname = $_POST['companyname'];
       $country = $_POST['country2'];
       $mail = new PHPMailer();
       $mail->isSMTP();                                      
       $mail->SMTPDebug = 2;  
       $mail->SMTPAuth = true;
       $mail->SMTPSecure = 'ssl';
       $mail->Host = "relay-hosting.secureserver.net"; 
       $mail->Port = 465;
       $mail->IsHTML(true);                                     
       $mail->Username = "xxxx@gmail.com";                 
       $mail->Password = "PASSword1@3";   
       $message = array();    
       $message[] = 'Name  :  '.trim($name).' ';        
       $message[]='Phone  :  '.trim($phone).' ';   
       $message[]='Email  :  '.trim($email).' '; 
       $message[]='Company Name  :  '.trim($companyname).' ';    
       $message[]='Country  :  '.trim($country).' ';    
       $message = implode('<br/>', $message);           
       $mail->SetFrom($email);
       $mail->Subject = 'Here is the subject';
       $mail->Body = $message;
       $mail->AddAddress($to); 
       if(!$mail->send()) {
            $msg = "Error while sending email";
            $msgclass = 'bg-danger';
            header("Location: /");
            die();    
       } 
       else {
          $msg = 'A mail with recovery instruction has sent to your email.';
          $msgclass = 'bg-success';
       }     
    }
?>

你用过gmail,你应该设置host为smtp.gmail.com,SMTPSecure为ssl,SMTPAuth为true,端口为465,你也应该使用app密码,你可以看到https://support.google.com/mail /answer/7126229

$mail = new PHPMailer();
   $mail->isSMTP();                                      
   $mail->SMTPDebug = 1;  
   $mail->SMTPAuth = false;
   $mail->SMTPSecure = 'none';
   $mail->Host = "localhost"; 
   $mail->Port = 25;
   $mail->IsHTML(true);         

Solved the issue with this update in SMTP解决了 SMTP 中此更新的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM