我正在使用PHPMailer类从我的联系表单发送电子邮件到localhost上的我的gmail帐户,它运行正常。但是当我在Hostgator服务器上传它时,我在尝试发送电子邮件时遇到错误。我是否使用IP地址或主机名以及我应该使用哪个端口?请协助?
PHPMailer类
if (selectedDate.after(currentDate)) {
// Do something here
} else {
// Print here "Please select date after current date"
}
错误
require ("PHPMailer/PHPMailerAutoload.php"); //including phpmailer class
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPDebug = 2;
$mail->Host = "108.167.172.144 "; //Server IP Address
$mail->SMTPSecure = "tls"; // Connect using a TLS connection
$mail->Port = 587; //Gmail SMTP port
$mail->SMTPAuth = true; // turn on SMTP authorization
$mail->Username = "*********@gmail.com"; // SMTP username
$mail->Password = "********"; // SMTP password
$mail->From = "$em"; //email of sender
$mail->FromName = "$nm"; //name of the sender
$mail->AddAddress("********@gmail.com", "Patwan"); //email address of recepient and name
$mail->AddReplyTo($em, $nm); //Address to which recepient will reply
$mail->WordWrap = 100; // set word wrap to 100 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Contact Form"; //subject of email
$mail->Body = "Name: " . $nm .
"<br>Phone: " . $phone .
"<br>Email: " . $em .
"<br>Subject: " . $value .
"<br>Message: " . $msg ;
答案 0 :(得分:0)
主机是“邮件。域名 .com”。 端口是465。 用户名是您在hostgator上创建的电子邮件帐户之一。 密码是电子邮件帐户的密码。 SMTPsecure是“ ssl”