![](/img/trans.png)
[英]combining phpmailer_v5.1 use_gmail with paypal ipn responder
[英]Unable to send email through gmail using PHPMailer_v5.1
我正在尝试使用PHPMailer_V5.1通过gmail发送电子邮件。
收到以下错误,
SMTP->错误:无法连接到服务器:无法找到套接字传输“ ssl”-在配置PHP时是否忘记启用它? (41961176)SMTP错误:无法连接到SMTP主机。
以下是PHPMailer下载随附的代码,我刚刚修改了必填字段,
<?php
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$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 = "santosh1984naidu@gmail.com"; // GMAIL username
$mail->Password = "********"; // GMAIL password
$mail->AddReplyTo('santosh1984naidu@gmail.com', 'First Last');
$mail->AddAddress('santosh1984naidu@gmail.com', 'John Doe');
$mail->SetFrom('santosh1984naidu@gmail.com', 'First Last');
$mail->AddReplyTo('santosh1984naidu@gmail.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
基于该错误,似乎PHP中未启用SSL。 我认为我需要忘掉评论
扩展名= PHP_openssl.dll
在您的php.ini文件中
如果已在系统上安装SSL,则以下内容应可帮助您安装SSL:
好吧,错误消息说明了一切:
找不到套接字传输“ ssl”-在配置PHP时是否忘记启用它?
这意味着PHP版本没有配备必要的库以通过SSL与邮件服务器(或与此有关的任何其他服务器)进行通信。
如果您无权访问服务器,则可能是服务器管理员/提供者遇到的问题。
我的猜测是,不是为Apache安装了mod_ssl还是已经安装了mod_ssl,但是在httpd.conf中注释掉了mod_ssl的配置行(就像我在suse9上一样)。 如果mod_ssl已启动并正在运行,则apxs仅在php中启用ssl函数
因此,请检查mod_ssl是否可用且已在apache中启用,然后尝试使用重新编译php
./configure --with-apxs2 = / usr / sbin / apxs --with-mysql --enable-ssl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.