改为:$mail_From="发件邮箱"$jmail->From = mb_convert_encoding($mail_From, 'GB2312', 'UTF-8') 同理,下面的FromName和Subject、Body都同样地处理即可。
<?class Jmail
{
public $Username //邮局用户名
public $Password //密码
public $FormName //发件人姓名
public $From //发件人地址
public $Addrecipient //收件人地址
public $Ttile //邮件标题
public $Content //邮件内容
public $Smtp//邮件服务器
function Send(){
$Jmail = new com("Jmail.Message") //实例化一个Jmail对象
$Jmail->SiLent=true//设置成True的话Jmail不会提示错误只会返回True和False
$Jmail->LogGing = false //是否开启日志
$Jmail->CharSet = "GB2312"//设定字符串编码
$Jmail->ContentType = "Text/html"//邮件的格式为HTML格式
$Jmail->MailServerUsername = $this->Username//发信箱用户名
$Jmail->MailServerPassword = $this->Password//发信箱密码
$Jmail->FromName = $this->FromName //发件人姓名
$Jmail->From = $this->From//发件人地址
$Jmail->AddRecipient($this->Addrecipient)//收件人地址
$Jmail->Subject = $this->Title//Email标题
$Jmail->Body = $this->Content//Email正文
$JmailError = $Jmail->Send($this->Smtp)//Smtp服务器
if($JmailError){ //判断邮件是否发送成功
return true
}else{
return false
}
}
}
//这里是调用代码
$jmail = new Jmail()
$jmail->Username = "lwf0757"
$jmail->Password = "0757"
$jmail->FromName = "梁"
$jmail->From = "lwf0757@163.com"
$jmail->Addrecipient = "313120799@qq.com"
$jmail->Title = "这是标题"
$jmail->Content = "这是内容"
$jmail->Smtp = "smtp.163.com"
if($jmail->Send()){
echo "成功哦!"
}else{
echo "失败哦!"
}
?>
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)