首页 > wordpress > 解决wordpress mu 收不到邮件问题

解决wordpress mu 收不到邮件问题

2008年5月23日 foolpig 发表评论 阅读评论

今天有个朋友说如何才能解决wordpress mu收不到邮件的问题呢?

我记得wordpress mu默认发送邮件是没有问题的,可是有些邮件服务器却无法收到,比如hotmail,估计是由于采用的Linux默认的sendmail,没有经过认证,所以被邮件服务器给丢弃了

那应该如何解决呢?
我以前写过一篇文章《让wordpress mu新用户注册后的密码明文显示,取消邮件通知》
上面有无法接收邮件时,直接在注册完成后显示用户和密码的方法

可是如果一定要使用邮件怎么办?
既然采用Linux内部的有时候收不到,那能不能采用外部的邮件系统呢?

仔细看了源码,发现wordpress使用的是phpmailer来进行邮件的发送
这样的话使用外部的邮件系统来发送应该问题不大,测试后采用如下步骤解决之:^__^

如果你觉得下面的东东比较麻烦,你可以点这里直接下载修改后的文章, 下载后解压至 /wp-includes/ 目录下, 记得要修改 mail-inc.php 文件中的邮件信息哦.

1)在 /wp-includes/ 新建 mail-inc.php 文件(这个文件主要是设置 SMTP 服务器的信息), 代码如下:

require("class-phpmailer.php");

class MyMailer extends PHPMailer {
// Set default variables for all new objects
var $Mailer = "smtp"; // Alternative to IsSMTP()
var $CharSet = "utf-8";
var $From = "你的邮件地址";
var $FromName = "name,你想起什么名字都可以";
var $Host = "smtp服务器地址";
var $Port = 25; //smtp server port
var $SMTPAuth = true;
var $Username = "你邮件的帐号";
var $Password = "你邮件的密码";
var $WordWrap = 75;
}
?>

2)打开 /wp-includes/pluggable.php, 查找 function wp_mail($to, $subject, $message, $headers = ”) { global $phpmailer;
在 global $phpmail; 其前面添加如下代码:

require(“mail-inc.php”);
$mail = new MyMailer;
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;

return $mail->Send();

3) 继续在此文件中查找 wp_new_user_notification 函数, 把:

wp_mail($user_email, sprintf(__(‘[%s] Your username and password’), get_settings(‘blogname’)), $message);
// 修改为:
@wp_mail($user_email, sprintf(__(‘[%s] Your username and password’), get_settings(‘blogname’)), $message);

好像就是在前面加上一个@而已.

4) 在文结尾(?>)前添加如下代码:

if ( !function_exists(‘wp_mail_attachment’) ) :
function wp_mail_attachment($to, $subject, $message, $string, $filename, $encoding, $type) {
require(“mail.inc.php”);

$mail = new MyMailer;
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddStringAttachment($string, $filename, $encoding, $type);

return $mail->Send();
}
endif;

如有疑问,欢迎后面留言 ^_^

  1. theboy
    2008年9月7日22:06 | #1

    Fatal error: Cannot redeclare class EkinMailer in /home1/eigzerbl/public_html/wp-includes/mail-inc.php on line 14我的激活时候出了这个,请问是怎么了.我的mu是2.6

  2. 2008年9月8日07:27 | #2

    您看一下pluggable.php文件的wp_mail函数中是否有这两行:
    require(“mail-inc.php”);
    $mail = new EkinMailer;

  3. mai
    2008年9月17日10:59 | #3

    我的情况也一样。Fatal error: Cannot redeclare class EkinMailer in /home1/eigzerbl/public_html/wp-includes/mail-inc.php on line 14
    刷新这个页面又正常了,估计是引用类的时候有点问题?
    我是严格按照博主说明的操作。
    另外还有一个问题。按照你所的改了以后,注册后会发一份邮件到你的邮箱(这正常),然后输入激活码,系统会提示给你的邮箱发送了密码(这份邮件收不到),只能点忘记密码(这时候又能收到系统发给你的忘记密码的邮件)。

  4. 2008年11月27日16:35 | #4

    我装的是2.6.2版的MU
    还装了buddypress
    请问该如何修改啊
    我照你这样改的有错误
    是说class-smtp.php这个文件出错

  5. 2009年3月12日15:21 | #5

    不错

  6. 2009年4月7日19:27 | #6

    其实,使用本机的SendMail发邮件,非常简单,当然,加入你的机器里装了SendMail的话。
    需要在/etc/mail/access里面,加入:
    Connect:192.168.1.100 RELAY
    这里,假设你的本机IP是192.168.1.100的话,如果不是请修改。
    注意:千万别去管什么防火墙设置

    然后——你随便,发就是了 :)

  7. 2012年1月12日19:30 | #7

    Offering will make your ft and further cozy design shoes using the world. Even now the stars also adore mens uggs this pair of shoes they are so tall need affordable Uggs can pick the shoe has its distinctive charm.
    With a reputation for design and feature, uggs usa outlet online can be found in everywhere.UGG outlet is even more convenient.
    The 5281 uggs kids classic boots she sent have been also merely a tiny far too significant so that they will previous a lot more than only a several months on my daughter’s feet.
    Our ugg outlet site wholesale ,retail and discount UGG of the product brand.UGG has been the practicality and durability of leather goods for their own mind, in a balance between traditional and popular.
    ugg gloves men with Side Straps: These gloves are also made up of sheep skin and can be entangled side ways.

    Uzgh usiftxr plvumrf vnxzgdd dwlgeum waoeshm eqdbpto 31,xmpbamv vszlttr weoalmo rpekigr z
    kids uggs
    Huad dtzebqe dgzzpur lapvgdd rjqtwzz blozirp agnnpvl 66,rfqwyug pnmonbf czocsbi fehollg t

  1. 2009年5月17日19:50 | #1
  2. 2009年10月23日15:45 | #2