Email 已在我的计算机上成功发送邮件,但使用phpmailer使服务器失败
您的主机可能已对使用的端口进行了防火墙。尝试使用其他端口(具有其他安全性)设置或联系您的主机。您是否有防火墙阻止访问端口465?你能在smtp.google.com上远程登录到465吗?我们如何在主机上检查它?如果你有对主机的服务器访问权限(SSL访问),你可以使用终端或Putty访问服务器,然后从它测试远程登录连接。某些主机在帐户的管理页面中也有防火墙设置。您有一些测试telnet连接的提示吗?它能做什么,不能做什么?谢谢,我想答案取决于您是否拥有对主机帐户的SSL终端访问权限。如果您有,您应该能够运行命令“telnet smtp.google.com 465”而不会出现错误。是否真的可以使用其他非标准端口访问smtp.gmail.com?引用google的任何点击:这是一个问题,因为google应用程序电子邮件帐户在端口465(用于SSL)或587(用于TLS)上使用smtp.gmail.com。无法通过此SMTP服务器进行未加密的发送。对于非安全连接,这里还有另一句话:答案是将SMTP.gmail.com设置替换为:server:aspmx.l.google.com端口:25Email 已在我的计算机上成功发送邮件,但使用phpmailer使服务器失败,email,phpmailer,php,Email,Phpmailer,Php,您的主机可能已对使用的端口进行了防火墙。尝试使用其他端口(具有其他安全性)设置或联系您的主机。您是否有防火墙阻止访问端口465?你能在smtp.google.com上远程登录到465吗?我们如何在主机上检查它?如果你有对主机的服务器访问权限(SSL访问),你可以使用终端或Putty访问服务器,然后从它测试远程登录连接。某些主机在帐户的管理页面中也有防火墙设置。您有一些测试telnet连接的提示吗?它能做什么,不能做什么?谢谢,我想答案取决于您是否拥有对主机帐户的SSL终端访问权限。如果您有,您应
<?php
date_default_timezone_set('America/Toronto');
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = "gdssdh";
//$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "myemail@gmail.com"; // GMAIL username
$mail->Password = "******"; // GMAIL password
$mail->SetFrom('mysent@gmail.com', 'PRSPS');
//$mail->AddReplyTo("user2@gmail.com', 'First Last");
$mail->Subject = "PRSPS password";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "mymail@yahoo.co.in";
$mail->AddAddress($address, "user2");
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}