首页 >后端开发 >php教程 >关于PHP发送邮件问题

关于PHP发送邮件问题

WBOY
WBOY原创
2016-07-06 13:53:10897浏览

<code>$mail = new PHPMailer; 
$mail->isSMTP();        
$mail->Host = 'smtp.163.com';   
$mail->SMTPAuth = true;
$mail->CharSet='UTF-8';     
$mail->Username = 'XXXX@163.com';  
$mail->Password = 'XXX';   
$mail->Port = 25;   
$mail->From = 'XXXX@163.com';            
$mail->FromName = 'XXXX';     
$mail->addAddress('XXX@qq.com');      
$mail->WordWrap = 50;                              
$mail->isHTML(true);                     
$mail->Subject = '发送邮件测试';
$mail->Body    = 'XXXX';
if(!$mail->send()) {
    echo '邮件发送失败.';
    echo '错误信息: ' . $mail->ErrorInfo;
} else {
    echo '邮件发送成功';
}
</code>

关于PHP发送邮件问题

回复内容:

<code>$mail = new PHPMailer; 
$mail->isSMTP();        
$mail->Host = 'smtp.163.com';   
$mail->SMTPAuth = true;
$mail->CharSet='UTF-8';     
$mail->Username = 'XXXX@163.com';  
$mail->Password = 'XXX';   
$mail->Port = 25;   
$mail->From = 'XXXX@163.com';            
$mail->FromName = 'XXXX';     
$mail->addAddress('XXX@qq.com');      
$mail->WordWrap = 50;                              
$mail->isHTML(true);                     
$mail->Subject = '发送邮件测试';
$mail->Body    = 'XXXX';
if(!$mail->send()) {
    echo '邮件发送失败.';
    echo '错误信息: ' . $mail->ErrorInfo;
} else {
    echo '邮件发送成功';
}
</code>

关于PHP发送邮件问题

https://github.com/kokororin/posutoba/tree/master/src/System/Library/Vendor/PHPMailer

<code>Vendor('PHPMailer.PHPMailerAutoload');
$mail = new \PHPMailer();</code>

用thinkphp框架的吧,把SMTP那个类文件的命名空间改为和你的phpmailer类一样的命名空间就好了,前几天刚刚配置过

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn