很多用户使用的虚拟主机都禁用了mail函数以至于网站无法发邮件(注册用户、找回密码等一些操作都需要发送邮件),虽然有很多SMTP插件可以解决此问题,但是,wordpress的原则是,能不用插件就坚决不用插件,特比是一些小功能,也没必要使用插件。
将以下代码插入到主题的functions.php里:

//使用smtp发邮件
function MBT_mail_smtp( $phpmailer ) {
$phpmailer->IsSMTP();
$phpmailer->SMTPAuth = true;//启用SMTPAuth服务
$phpmailer->Port = 25;//MTP邮件发送端口,这个和下面的对应,如果这里填写25,则下面为空白
$phpmailer->SMTPSecure =" ";//是否验证 ssl,这个和上面的对应,如果不填写,则上面的端口须为25
$phpmailer->Host = "smtp.126.com";//邮箱的SMTP服务器地址,如果是QQ的则为:smtp.exmail.qq.com
$phpmailer->Username = "haitaoketang@126.com";//你的邮箱地址
$phpmailer->Password ="MBFRWDCLIVCFITIE";//你的邮箱登录密码
}
add_action('phpmailer_init', 'MBT_mail_smtp');
//下面这个很重要,得将发件地址改成和上面smtp邮箱一致才行。
function MBT_wp_mail_from( $original_email_address ) {
return 'haitaoketang@126.com';
}
add_filter( 'wp_mail_from', 'MBT_wp_mail_from' );
配置完成后,基本就没多大问题了。插件用多的是真的卡啊