|
在用phpmailer发送中文内容的邮件时,经常出现乱码,本文给出一个例子,主要是加上了编码设置base64,可以解决乱码的问题,供大家参考。
使用PHPMailer类发送邮件,
代码如下:
我秀秀淘宝客api源码
查看详情
程序介绍:程序采用.net 2.0进行开发,全自动应用淘客api,自动采集信息,无需,手工更新,源码完全开放。(程序改进 无需填入阿里妈妈淘客API 您只要修改app_code文件下的config.cs文件中的id为你的淘客id即可)针对淘客3/300毫秒的查询限制,系统采用相应的解决方案,可以解决大部分因此限制带来的问题;程序采用全局异常,避免偶尔没考虑到的异常带来的问题;程序源码全部开放,请使
0
<?php
/**
* 解决phpmailer发邮件中文乱码
* edit bbs.it-home.org
*/
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='程序员之家_bbs.it-home.org -欢迎大家的光临!';
$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下载地址 |
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号