[英]Xampp on ubuntu server 12.04 with pear installed returns errors when trying to use php mail()
我正在尝试让php在创建帐户时向新用户发送激活电子邮件。 我的问题不是此过程的代码,而是php发送电子邮件。
到目前为止,我已经在安装了Kubuntu桌面的Ubuntu服务器12.04上安装了Xampp。 我还使用sudo apt-get install php-pear
命令sudo apt-get install php-pear
。
最后我安装了postfix。 在浏览器中加载页面时,出现以下错误:
不建议使用:在第55行的/opt/lampp/lib/php/Mail.php中,不建议通过引用分配new的返回值
不建议使用:在第135行的/opt/lampp/lib/php/Mail.php中,不建议通过引用分配new的返回值
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ this来自第167行的/opt/lampp/lib/php/Mail/smtp.php中不兼容的上下文
严格的标准:非静态方法PEAR :: isError()不应静态调用,假设$ this来自第290行的/opt/lampp/lib/php/Net/SMTP.php中不兼容的上下文
严格标准:非静态方法PEAR :: raiseError()不应静态调用,假定$ this来自第168行的/opt/lampp/lib/php/Mail/smtp.php中不兼容的上下文
感谢您的回复! 虽然我的代码在这里,但我仍然遇到一些问题:
<?php
include("Mail.php");
$recipients = "noreply.njmedia@gmail.com";
$headers["From"] = "noreply.njmedia@gmail.com";
$headers["To"] = "noreply.njmedia@gmail.com";
$headers["Subject"] = "Test message";
$body = "TEST MESSAGE!!!";
$params["host"] = "smtp.google.com";
$params["port"] = "465";
$params["auth"] = true;
$params["username"] = "noreply.njmedia@gmail.com";
$params["password"] = "gmailpassword(my real password is entered here)";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
?>
这是调试的结果:
object(PEAR_Error)#4 (8) {
["error_message_prefix"]=> string(0) ""
["mode"]=> int(1)
["level"]=> int(1024)
["code"]=> NULL
["message"]=> string(52) "unable to connect to smtp server smtp.google.com:465"
["userinfo"]=> NULL
["backtrace"]=> array(3) { [0]=> array(6) { ["file"]=> string(27) "/opt/lampp/lib/php/PEAR.php" ["line"]=> int(533) ["function"]=> string(10) "PEAR_Error" ["class"]=> string(10) "PEAR_Error" ["type"]=> string(2) "->" ["args"]=> array(5) { [0]=> string(52) "unable to connect to smtp server smtp.google.com:465" [1]=> NULL [2]=> int(1) [3]=> int(1024) [4]=> NULL } } [1]=> array(7) { ["file"]=> string(32) "/opt/lampp/lib/php/Mail/smtp.php" ["line"]=> int(169) ["function"]=> string(10) "raiseError" ["class"]=> string(4) "PEAR" ["object"]=> object(Mail_smtp)#1 (10) { ["host"]=> string(15) "smtp.google.com" ["port"]=> string(3) "465" ["auth"]=> bool(true) ["username"]=> string(25) "noreply.njmedia@gmail.com" ["password"]=> string(28) "Fakepasswordforstackoverflow" ["localhost"]=> string(9) "localhost" ["timeout"]=> NULL ["verp"]=> bool(false) ["debug"]=> bool(false) ["sep"]=> string(2) " " } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(52) "unable to connect to smtp server smtp.google.com:465" } } [2]=> array(7) { ["file"]=> string(32) "/media/HDD2/NJmedia/mailtest.php" ["line"]=> int(23) ["function"]=> string(4) "send" ["class"]=> string(9) "Mail_smtp" ["object"]=> object(Mail_smtp)#1 (10) { ["host"]=> string(15) "smtp.google.com" ["port"]=> string(3) "465" ["auth"]=> bool(true) ["username"]=> string(25) "noreply.njmedia@gmail.com" ["password"]=> string(28) "Fakepasswordforstackoverflow" ["localhost"]=> string(9) "localhost" ["timeout"]=> NULL ["verp"]=> bool(false) ["debug"]=> bool(false) ["sep"]=> string(2) " " } ["type"]=> string(2) "->" ["args"]=> array(3) { [0]=> string(25) "noreply.njmedia@gmail.com" [1]=> array(3) { ["From"]=> string(25) "noreply.njmedia@gmail.com" ["To"]=> string(25) "noreply.njmedia@gmail.com" ["Subject"]=> string(12) "Test message" } [2]=> string(15) "TEST MESSAGE!!!" } } }
["callback"]=> NULL
}
使用命令: whereis pear
它会给你梨的道路。
sudo <the path where Pear is located> install mail <br/>
sudo <the path where Pear is located> install Net_SMTP <br/>
sudo <the path where Pear is located> install Auth_SASL <br/>
sudo <the path where Pear is located> install mail_mime <br/>
对我来说
sudo /opt/lampp/bin/pear install mail <br/>
sudo /opt/lampp/bin/pear install Net_SMTP <br/>
sudo /opt/lampp/bin/pear install Auth_SASL <br/>
sudo /opt/lampp/bin/pear install mail_mime <br/>
请重启您的XAMP服务器
启动兰普
sudo /opt/lampp/lampp start
停止兰普
sudo /opt/lampp/lampp stop
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.