首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装了pear的ubuntu服务器12.04上的Xampp在尝试使用php mail()时返回错误

问安装了pear的ubuntu服务器12.04上的Xampp在尝试使用php mail()时返回错误
EN

Stack Overflow用户
提问于 2012-08-23 00:00:19
回答 1查看 1.9K关注 0票数 0

我试图获得一个php发送一个新的用户,激活电子邮件时,创建一个帐户。我的问题不是这个过程的代码,而是php发送电子邮件。

到目前为止,我已经在Ubuntu服务器12.04上安装了Xampp,安装了Kubuntu桌面。我还使用sudo apt-get install php-pear命令安装了pear。

最后,我安装了后缀。当我在浏览器中加载页面时,会收到以下错误:

弃用:在第55行的/opt/lampp/lib/php/Mail.php中,不再推荐通过引用分配新的返回值 弃用:在第135行的/opt/lampp/lib/php/Mail.php中,不再推荐通过引用分配新的返回值 严格标准:非静态方法PEAR::isError()不应该静态调用,假设$this来自第167行/opt/lampp/lib/php/Mail/smtp.php中不兼容的上下文 严格标准:非静态方法PEAR::isError()不应该静态调用,假设$this来自/opt/lampp/lib/php/Net/smt.php中的第290行中不兼容的上下文 严格标准:非静态方法PEAR::raiseError()不应该静态调用,假设$this来自第168行/opt/lampp/lib/php/Mail/smtp.php中不兼容的上下文

谢谢你的回复!虽然下面是我的代码,但我仍然有一些问题:

代码语言:javascript
复制
<?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); 
?>

以下是调试的结果:

代码语言:javascript
复制
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
}
EN

回答 1

Stack Overflow用户

发布于 2012-11-03 11:48:49

使用命令:whereis pear

它会给你一条梨树之路。

代码语言:javascript
复制
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/>

对我来说

代码语言:javascript
复制
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/>

请使用

启动灯

代码语言:javascript
复制
sudo /opt/lampp/lampp start

停止兰普

代码语言:javascript
复制
sudo /opt/lampp/lampp stop

谢谢

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12083025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档