我不理解PHP邮件程序错误:邮件未发送..邮件程序错误:SMTP connect()失败

我不理解PHP邮件程序错误:邮件未发送..邮件程序错误:SMTP connect()失败,php,email,Php,Email,文件来自 错误:邮件未发送..邮件程序错误:SMTP connect()失败 require_一次('./class.phpmailer.php') $mail=new PHPMailer() $mail->IsSMTP() $mail->Host=“smtp.gmail.com” $mail->Port=“465” $mail->SMTPAuth=“true” $mail->SMTPSecure=“ssl” $mail->Username=”mymail@gmail.com" $mail->P

文件来自 错误:邮件未发送..邮件程序错误:SMTP connect()失败

require_一次('./class.phpmailer.php')
$mail=new PHPMailer()
$mail->IsSMTP()
$mail->Host=“smtp.gmail.com”
$mail->Port=“465”
$mail->SMTPAuth=“true”
$mail->SMTPSecure=“ssl”
$mail->Username=”mymail@gmail.com"
$mail->Password=“Password”
//构建消息
$mail->IsHTML(真)
$mail->From=”mymail@gmail.com"
$mail->AddAddress(“mymail@mydomain.com")
$mail->Subject=“HTML邮件”
$mail->Body=“你好,我的朋友!\n\n此邮件使用HTML实体!”
如果($mail->Send()){
回显“消息已发送”
} 
否则{
回显“未发送消息…”
回显“邮件错误:”。$mail->ErrorInfo
}

必须启用OpenSSL。例如,在php.ini中,删除“;”在线:

extension=php_openssl.dll
为了查看,如果您启用了“OpenSSL”,请创建一个新的php文件,将其放入:

<?php echo phpinfo();?>
-----添加完整的代码-------------

我已经测试了此代码,它正在为我运行:

<?php
require_once('./class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP() ;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth  = true ;
$mail->SMTPSecure = "ssl";
$mail->Username = "mymail@gmail.com";
$mail->Password = "mypassword";


//build the message
 $mail->IsHTML(true);
$mail->From     = "mymail@gmail.com";
$mail->AddAddress("mymail@gmail.com");
$mail->Subject  = "An HTML Message";
$mail->Body     = "Hello, <b>my friend</b>! \n\n This message uses HTML entities!";

if($mail->Send()) {
  echo 'Message is sent';

} 
else {
  echo 'Message was not sent..';
 echo 'Mailer error: ' . $mail->ErrorInfo;
}
?>

防火墙会阻止该端口。或者您使用了错误的端口/protocol/etc.open命令行(cmd.exe)并尝试通过telnet:telnet smtp.gmail.com 465进行连接(抱歉,我不擅长英语)谢谢。我发了电子邮件。但是,由主办方决定。邮件未发送..邮件程序错误:SMTP connect()失败。请检查是否有OpenSSL。
OpenSSL support :   enabled 
<?php
require_once('./class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP() ;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth  = true ;
$mail->SMTPSecure = "ssl";
$mail->Username = "mymail@gmail.com";
$mail->Password = "mypassword";


//build the message
 $mail->IsHTML(true);
$mail->From     = "mymail@gmail.com";
$mail->AddAddress("mymail@gmail.com");
$mail->Subject  = "An HTML Message";
$mail->Body     = "Hello, <b>my friend</b>! \n\n This message uses HTML entities!";

if($mail->Send()) {
  echo 'Message is sent';

} 
else {
  echo 'Message was not sent..';
 echo 'Mailer error: ' . $mail->ErrorInfo;
}
?>
http://blog.portekoi.com/stack/Mailer.zip