使用GoDaddy的SMTP服务器电子邮件无法连接

时间:2018-12-13 22:15:23

标签: php smtp phpmailer server-side godaddy-api

我正尝试使用GoDaddy的PHPMailer服务器使用SMTP发送电子邮件(因为我听说它们阻止了Gmail的SMTP,否则我会使用它)。这是我的代码:

<?php

require_once "vendor/autoload.php";


$name = $_POST["name"];
$email_from = $_POST["email"];
$telephone = $_POST["telephone"];

$message = "Name:  ".$name."\r\n".
"Email:  ".$email_from."\r\n".
"Telephone:  ".$telephone."\r\n";
$email_to = "myemail@gmail.com";

if(isset($_POST['submit'])){

    $mail = new PHPMailer\PHPMailer\PHPMailer;

    $mail->isSMTP();
    $mail->Host = "localhost";
    $mail->SMTPAuth = false;
    $mail->Port = 50;


    $mail->From = $email_from;
    $mail->FromName = $name;
    $mail->addAddress($email_to);

    $mail->addReplyTo($email_from);
    $mail->Subject = "Info";
    $mail->Body = $message;


    if ($_POST["submit"]){
        if(!$mail->send()){
            echo "Mailer error: " . $mail->ErrorInfo;
        }
        else{
            echo "Message sent successfully";
        }

    }

}

我查找了许多解决方案,但找不到任何有帮助的方法。基本上没有我尝试过的GoDaddy SMTP配置。我收到错误:Mailer error: SMTP connect() failed. https://github.com/PHPMailer/wiki/Troubleshooting

我应该如何配置它使其起作用?谢谢。

0 个答案:

没有答案