在LAMP环境下pear::Mail发送邮件错误sendmail returned error code 78 的解决
来源:互联网 发布:狂飙一号 知乎 编辑:程序博客网 时间:2024/05/21 04:22
我在LAMP环境下在安装statusnet的时候遇到最大的一个问题就是在用户注册时,输入用户的电子邮件地址,注册后就会显示如下的错误:
Database error
An important error occured, probably related to email setup. Check logfiles for more info..
对于这个问题我一直无法解决。
随着我对statusnet的深入剖析和学习,随着一步一步的深入代码我终于找到了这个问题的根本原因所在。在statusnet根目录/class/User.php中
if ($email && !$user->email) {
mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
这段调用了statusnet根目录/lib/mail.php中的函数,最终调用这个函数
function mail_send($recipients, $headers, $body)
{
// XXX: use Mail_Queue... maybe
$backend = mail_backend();
if (!isset($headers['Content-Type'])) {
$headers['Content-Type'] = 'text/plain; charset=UTF-8';
}
assert($backend); // throws an error if it's bad
$sent = $backend->send($recipients, $headers, $body);
if (PEAR::isError($sent)) {
common_log(LOG_ERR, 'Email error: ' . $sent->getMessage());
return false;
}
return true;
}
在这里你要在config.php中配置下你的邮件选项,如果你使用的是linux下默认的sendmail就可以如下配置
$config['mail']['notifyfrom'] = 'blog@xiaofei.zgch.gov.cn';//寄送确认信件的发送邮件地址
$config['mail']['domain'] = 'xiaofei.zgch.gov.cn';//所在的主机和域名的全称(这里主机名xiaofei,域名zgch.gov.cn)
$config['mail']['backend'] = 'sendmail';//你所用的发送邮件的服务(我用的是linux下默认的sendmail)
$config['mail']['params'] = array('sendmail_path' => '/usr/sbin/sendmail','sendmail_args' => '-oi -t');//我用的是fedora12,默认sendmail路径
注意sendmail_args的参数
Two useful flags to pass sendmail are -oi and -t. The -oi flag tells sendmail not to
think a single dot (.) on a line is the end of the message. The -t flag makes sendmail
parse the file for To: and other header lines.
这样配置你就会遇到文章开始处的错误。你会看到apache的错误和statusnet本身的错误都指向了mail的配置。只好来看看sendmail本身的log,在这里/var/log/maillog,你会看到这样的错误
Mar 23 15:51:11 xiaofei sendmail[3773]: NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied
这个好像是说apache没有这个目录的权限,网上有的解决方案是如下改变该目录的权限
chmod 777 /var/spool/clientmqueue
但是这样是无济于事的。你应该这样干
/usr/sbin/setsebool -P httpd_can_sendmail=on
原因是apache默认并不运行sendmail。你必须手动开启。这里手的比较详尽:
By default, Apache is not allowed to run Sendmail. This is a security feature.
To enable it, go to a root prompt and do:
/usr/sbin/setsebool -P httpd_can_sendmail=on
I have tried changing permissions but I get no where.
It's not a "file permissions" problem, as such -- you should put them back to how they're supposed to be.
这样改完了你的邮件设置才正确,才能正确的从statusnet发送确认信件到用户输入的邮箱。
还有一点值得注意:你最好把你误用chmod 777 /var/spool/clientmqueue改的目录权限改过来,不然/var/log/maillog会提示你
Mar 23 16:07:40 xiaofei sendmail[3840]: dangerous permissions=40777 on queue directory /var/spool/clientmqueue/
这是“很危险的”!!!
- 在LAMP环境下pear::Mail发送邮件错误sendmail returned error code 78 的解决
- 在LAMP环境下pear::Mail发送邮件错误sendmail returned error code 78 的解决(二)
- 终端下sendmail接收/发送邮件错误
- 关于pear mail的发送中文邮件乱码可以参考
- php实现自动发送邮件pear Mail
- php使用pear mail发送邮件
- PHP使用pear实现mail发送功能 windows环境下配置pear
- mail发送邮件遇到的sb错误
- Linux下sendmail发送邮件
- Linux下sendmail发送邮件
- python使用sendmail在linux下发送邮件
- 在Centos7下捣鼓邮件发送软件sendmail与postfix
- 安装vs2008出现MSI returned error code 1603的错误的解决
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 在PHP中使用Pear 的NetMail发送smtp邮件
- 浅谈Java多线程的同步问题
- ImageMagicK的使用
- 高级定制的“疯狂”
- 管理的几点领悟...
- SQL Server Index系列之二
- 在LAMP环境下pear::Mail发送邮件错误sendmail returned error code 78 的解决
- 查询分析器调用存储过程的格式
- C#编写最小化时隐藏为任务栏图标的Window appllication.
- WPF(Windows Presentation Foundation)
- vc修改列表框LISTBOX的背景颜色及字体颜色及其使用方法
- 在Delphi中操作快捷方式
- LINQ 快速开发设计最佳实践
- Web 设计与开发终极资源
- 很强悍的js获取request参数的方法