教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 phpmailer发邮件中文乱码问题如何解决

phpmailer发邮件中文乱码问题如何解决

发布时间:2016-01-11   编辑:jiaochengji.com
在用phpmailer发送中文内容的邮件时,经常出现乱码,本文给出一个例子,主要是加上了编码设置base64,可以解决乱码的问题,供大家参考。
使用PHPMailer类发送邮件,

代码如下:

<?php
/**
 * 解决phpmailer发邮件中文乱码
 * edit www.jbxue.com
*/

set_time_limit(0);

include("class.phpmailer.php");
include("class.smtp.php");

$mail=new PHPMailer();

function send_email($mail,$reply_to,$to,$receive_name,$subject,$content)
{
 $mail->IsSMTP();
 $mail->CharSet = "GB2312";                     //chinese;
 $mail->Encoding = "base64";
 $mail->SMTPAuth   = true;
 $mail->SMTPSecure = "ssl";
 $mail->Host       = " smtp ";                  // set smtp server domain or ip;
 $mail->Port       = 465;
 $mail->Username   = " login account ";        // login account;
 $mail->Password   = " login password ";       // login password
 $mail->From       = " login account ";        // login account;
 $mail->FromName   = "sender name";            // sender name;
 $mail->Subject    = "$subject";
 $mail->Body       = "$content";
 $mail->AltBody    = "$content";
 $mail->WordWrap   = 50000;
 $mail->AddAddress($to,$receive_name);
 $mail->AddReplyTo("$reply_to","");             // reply to whom;
 $mail->AddAttachment("/path/to/file.zip");
 $mail->AddAttachment("/path/to/image.jpg", "new.jpg");
 $mail->IsHTML(true);
 
 if(!$mail->Send())
 {
  $send_result=$mail->ErrorInfo;  
 }
 else
 {
  $time=time();
  $time=date("Y-m-d H:i:s A");
  $send_result="Email sent to $to, at $time, Success";  
 } 
 return($send_result);
}

/*
the following code is a simple;
*/
$reply_to='sender@jbxue.com';
$to='customer@jbxue.com';
$receive_name='Carson';
$subject='脚本学堂_www.jbxue.com -欢迎大家的光临!';
$content='<h1><font color=#f00>this is a test.<br>last one</font></h1>';

$send_email=send_email($mail,$reply_to,$to,$receive_name,$subject,$content);
echo $send_email;
?>

附:PHPMailer邮件发送类V5.1下载地址
 

您可能感兴趣的文章:
PHPMailer发送邮件的实例分享
phpmailer发送gmail邮件的例子
phpmailer发送网易126邮箱的例子
phpmailer发送yahoo邮件的例子
phpmailer类实现邮件群发的实例代码
PHPMailer发送邮件代码实例(ubuntu系统)
PHPMailer发送带附件邮件的例子
PHPMailer收发邮件标题、发件人、内容乱码问题的终极解决方法
PHPmailer发送邮件及乱码问题的解决
PHPMailer发送邮件中文附件名乱码的解决办法
PHPMailer邮件标题中文乱码的解决方法
PHPMailer邮件类发送邮件举例(163邮箱)
phpmailer 发送邮件中文乱码问题的解决方法总结
phpmailer发送邮件及实现密码找回功能的代码
PHPmailer邮件群发的入门例子
PHPmailer 邮件群发的范例参考
phpmailer 类发送邮件乱码解决方法
PHPMailer批量发送邮件的实例代码
有关phpmailer的用法
php使用phpMailer发送邮件的例子
phpmailer实现的简单openvpn用户认证的代码
PHPMailer 中文使用说明
phpmailer发送邮件的例子

您可能感兴趣的文章:
phpmailer发送yahoo邮件的例子
phpmailer 类发送邮件乱码解决方法
PHPmailer邮件群发的入门例子
PHPMailer发送邮件中文附件名乱码的解决办法
PHPMailer邮件标题中文乱码的解决方法
PHPMailer发送邮件代码实例(ubuntu系统)
phpmailer发送gmail邮件的例子
phpmailer发送网易126邮箱的例子
phpmailer 发送邮件中文乱码问题的解决方法总结
phpmailer发邮件中文乱码问题如何解决

关键词: PHPMailer  发送邮件  中文乱码   
[关闭]
~ ~