我正尝试使用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
。
我应该如何配置它使其起作用?谢谢。