windows空间如何实现邮件发送
1、打开/wp-includes/目录下的class-phpmailer.php,查找class.smtp.php将其替换成class-smtp.php
2、在/wp-includes/目录下新建立mail.inc.php(设置发送邮件需要使用的smtp),代码如下
<?php
require("class.phpmailer.php");
classMyMailerextendsPHPMailer{
//Setdefaultvariablesforallnewobjects
var$Mailer="smtp";//AlternativetoIsSMTP()
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$SMTPDebug=true;
var$WordWrap=75;
}
?>
打开/wp-includes/pluggable.php,查找function wp_mail($to, $subject, $message, $headers = '') {
global $phpmailer;在global $phpmailer;其前面添加如下代码
require("mail.inc.php");
$mail=newMyMailer;
$mail->AddAddress($to);
$mail->Subject=$subject;
$mail->Body=$message;
return$mail->Send();
在此文件中查找wp_new_user_notification函数,修改其中的一行代码:
把
wp_mail($user_email,sprintf(__('[%s]Yourusernameandpassword'),get_settings('blogname')),$message);
修改成
@wp_mail($user_email,sprintf(__('[%s]Yourusernameandpassword'),get_settings('blogname')),$message);
3、在文件结尾?>前添加如下代码
if(!function_exists('wp_mail_attachment')):
functionwp_mail_attachment($to,$subject,$message,$string,$filename,$encoding,$type){
require("mail.inc.php");
$mail=newMyMailer;
$mail->AddAddress($to);
$mail->Subject=$subject;
$mail->Body=$message;
$mail->AddStringAttachment($string,$filename,$encoding,$type);
return$mail->Send();
}
endif;
阅读量:184
阅读量:150
阅读量:117
阅读量:98
阅读量:126