phpBB's Failed Sending Email Errors (and how to resolve)

Description: This article targets the "failed sending email" error on UNIX and people using PHP's mail() function (not phpBB's SMTP function)
Author: dougk_ff7
Date: Thu Jan 29, 2004 4:15 am
Type: Fix
Keywords: email,sendmail,mail,unix
Category: Installing/upgrading/converting
Recently, I've been playing around with some stuff that uses mail() in PHP, and I know I've hit errors in the past when I've set phpBB to use the mail() function, and I never really figured out why each case was failing. It started when I got the real error from PHP (when another program called mail()) -- "PHP Fatal Error: Call to undefined function mail()" -- looking around for a bit, I found that there are a few things that can cause this. One is simply PHP can't find sendmail, so you need to point it in the right direction using the "sendmail_path" option in php.ini. If that fails to work, you're going to have to do a bit more work. Create a new .php file (for example, phpinfo.php), with only "<?php phpinfo() ?>" (without quotes) in it. Upload this to your server, and view it with your web browser. Look down a bit until you see "sendmail_path" -- I found if this is broken, it usually displays "-t -i" -- the default parameters it uses for sendmail, and nothing else. Ok, so that was kinda pointless. It doesn't tell us very much more. Anyway, now the real reason for creating the phpinfo() file. Please follow these steps *exactly* (or modify slightly for your setup, you'll get the idea):

  • Copy that entire ./configure line up at the top of the phpinfo() page -- it'll make your life much less painful, trust me. Don't worry about the single quotes, they're fine. Just leave them.
  • Check for a working sendmail -- postfix and most other MTAs should provide this, qmail will provide a compatible warpper. Just make sure there's something. /usr/lib/sendmail, /usr/bin/sendmail, and /usr/sbin/sendmail are good bets, as far as I know. If your sendmail is elsewhere, make a symlink back to /usr/sbin/sendmail ("ln -s /path/to/your/sendmail /usr/sbin/sendmail") -- for qmail, that's "ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail"
  • Either grab the latest source of PHP, or find the source you built PHP from (this will require root later on, so if you're on a shared host, see if the problem exists outside of phpBB, and if it does, ask them to work on it for you).
  • If you are using a clean source tree, skip this step. If not, run make clean.
  • Run the ./configure line you just copied, or if you wish, reconfigure php to your liking. Hey, you're going to redo the entire thing, why not do it right?
  • Run make, su to root, and make install.
  • Check php.ini (if you don't know where it is, try "locate php.ini") -- make sure the sendmail_path is correct.
  • Run apachectl stop, followed by apachectl start(ssl)? -- if you use ssl, use startssl, if not, just use start. I found that apachectl restart seems to have some strange quirks, and may just die on you after rebuilding PHP. If you can't find apachectl, try "locate apachectl" or "whereis apachectl" to help you out.
  • Test mail() using a simple script. Unfortunately, I don't have one made. Perhaps [url]php.net[/url] would have an idea?


That's it. Hope this helps someone out there!

Good luck!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要批量插入数据到phpBB数据库,你可以使用SQL语句来实现。以下是一个示例代码,假设你要批量插入用户数据: ```php <?php // 连接到数据库 $dbhost = '数据库主机名'; $dbuser = '数据库用户名'; $dbpass = '数据库密码'; $dbname = '数据库名'; $dbport = '数据库端口(可选)'; $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport); // 检查连接是否成功 if (!$conn) { die("连接失败: " . mysqli_connect_error()); } // 定义要插入的用户数据数组 $users = array( array('用户名1', '密码1', '电子邮件1'), array('用户名2', '密码2', '电子邮件2'), // 添加更多用户数据... ); // 构建插入语句 $sql = "INSERT INTO phpbb_users (username, user_password, user_email) VALUES "; foreach ($users as $user) { $username = mysqli_real_escape_string($conn, $user[0]); $password = mysqli_real_escape_string($conn, $user[1]); $email = mysqli_real_escape_string($conn, $user[2]); $sql .= "('$username', '$password', '$email'), "; } $sql = rtrim($sql, ", "); // 去除最后一个逗号和空格 // 执行插入语句 if (mysqli_query($conn, $sql)) { echo "数据插入成功"; } else { echo "插入数据时出错: " . mysqli_error($conn); } // 关闭数据库连接 mysqli_close($conn); ?> ``` 请注意,上述代码中的数据库表名和字段名可能需要根据你的实际情况进行修改。此外,确保在插入之前对用户数据进行适当的验证和清理,以防止SQL注入等安全问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值