前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >用phpmailer发邮件 中文乱码问题解决

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

作者头像
deepcc
发布2018-05-16 15:57:43
1K0
发布2018-05-16 15:57:43
举报
文章被收录于专栏:deepccdeepcc

加入如下代码解决。

代码语言:javascript
复制
$mail->CharSet = "GB2312"; //utf-8;
$mail->Encoding = "base64";
代码语言:javascript
复制
<?php
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";                     //utf-8;
 $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@domain.com';
$to='customer@domain.com';
$receive_name='Carson';
$subject='xd function test last one';
$content='<h1><font color=#f00>xd function test<br>last one</font></h1>';

$send_email=send_email($mail,$reply_to,$to,$receive_name,$subject,$content);
echo $send_email;
?>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-05-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档