发送邮件报错误:PEAR mail package is not installed的原因是linux中缺少PEAR mail组件,
PEAR mail组件也就是PHP Pear Mail / SMTP软件包的三大支持:
1)NET / SMTP:SMTP协议的实现
2)邮件:提供发送邮件的多个接口的类
3)网络/ Socke:网络接口
解决方法:在php pear repo中下载并安装
1.下载文件
[root@tele-2 ~]# cd /tmp [root@tele-2 tmp]# wget http://download.pear.php.net/package/Mail-1.1.14.tgz [root@tele-2 tmp]# wget http://download.pear.php.net/package/Net_SMTP-1.2.10.tgz [root@tele-2 tmp]# wget http://download.pear.php.net/package/Net_Socket-1.0.8.tgz
2.解压文件
[root@tele-2 tmp]# tar -zxvf Mail-1.1.14.tgz [root@tele-2 tmp]# tar -zxvf Net_SMTP-1.2.10.tgz [root@tele-2 tmp]# tar -zxvf Net_Socket-1.0.8.tgz
3.安装文件
[root@tele-2 tmp]# cd /usr/share/pear [root@tele-2 pear]# mkdir Net [root@tele-2 pear]# cd Net [root@tele-2 Net]# cp /tmp/Net_SMTP-1.2.10/SMTP.php . [root@tele-2 Net]# cp /tmp/Net_Socket-1.0.8/Socket.php . [root@tele-2 Net]# cd .. [root@tele-2 pear]# cp -avr /tmp/Mail-1.1.14/Mail/ . ‘/tmp/Mail-1.1.14/Mail/’ -> ‘./Mail’ ‘/tmp/Mail-1.1.14/Mail/null.php’ -> ‘./Mail/null.php’ ‘/tmp/Mail-1.1.14/Mail/mail.php’ -> ‘./Mail/mail.php’ ‘/tmp/Mail-1.1.14/Mail/smtp.php’ -> ‘./Mail/smtp.php’ ‘/tmp/Mail-1.1.14/Mail/sendmail.php’ -> ‘./Mail/sendmail.php’ ‘/tmp/Mail-1.1.14/Mail/RFC822.php’ -> ‘./Mail/RFC822.php’ [root@tele-2 pear]# cp -avr /tmp/Mail-1.1.14/Mail.php . ‘/tmp/Mail-1.1.14/Mail.php’ -> ‘./Mail.php’
然后再项目中重新测试即可
帮助链接:https://www.cyberciti.biz/tips/rhel-install-php-net-smtp-email-socket.html