我在网上找到的发邮件的代码,其它都可以。就内容是个乱码。如果把邮箱的编码改成gb2312就可以正常显示。
可是内容以后会写韩文的。所以一定要用utf-8
高手帮帮忙。在线等。
<?
require_once ('email.class.php');
//##########################################
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$smtpserver = "mail.hotkr.com";//SMTP服务器
$smtpserverport =25;//SMTP服务器端口
$smtpusermail = "[email protected]*";//SMTP服务器的用户邮箱
$smtpemailto = "[email protected]";//发送给谁
$smtpuser = "[email protected]";//SMTP服务器的用户帐号
$smtppass = "alilang123";//SMTP服务器的用户密码
$mailsubject = " 主题目 ";//邮件主题
$mailsubject = "=?UTF-8?B?".base64_encode($mailsubject)."?=";
$mailbody = "<h1> 这是一个测试程序 </h1>";//邮件内容
$mailbody = iconv('gb2312','utf-8',$mailbody);
//$mailbody = "=?UTF-8?B?".base64_encode($mailbody)."?=";
$mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
$smtp->debug = TRUE;//是否显示发送的调试信息
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);
?>
可是内容以后会写韩文的。所以一定要用utf-8
高手帮帮忙。在线等。
<?
require_once ('email.class.php');
//##########################################
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$smtpserver = "mail.hotkr.com";//SMTP服务器
$smtpserverport =25;//SMTP服务器端口
$smtpusermail = "[email protected]*";//SMTP服务器的用户邮箱
$smtpemailto = "[email protected]";//发送给谁
$smtpuser = "[email protected]";//SMTP服务器的用户帐号
$smtppass = "alilang123";//SMTP服务器的用户密码
$mailsubject = " 主题目 ";//邮件主题
$mailsubject = "=?UTF-8?B?".base64_encode($mailsubject)."?=";
$mailbody = "<h1> 这是一个测试程序 </h1>";//邮件内容
$mailbody = iconv('gb2312','utf-8',$mailbody);
//$mailbody = "=?UTF-8?B?".base64_encode($mailbody)."?=";
$mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
$smtp->debug = TRUE;//是否显示发送的调试信息
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);
?>
你去下一个phpmailer
下面这个代码就可以拿来直接用了..(ps: phpmailer官方文档里面有例子)//phpmailer类
require_once("./plugin/phpmailer/class.phpmailer.php");
require_once("./plugin/phpmailer/class.smtp.php");//自己写的function
function SendMailToClient($client){
$mail = new PHPMailer(); //$mail->SMTPDebug = 2; // debug选项
$mail->CharSet = "UTF-8"; // 设置编码 $mail->IsSMTP();
$mail->SMTPAuth = true; // 设置为安全验证方式
$mail->Host = "smtp.qq.com"; // SMTP服务器地址
$mail->Username = "[email protected]"; // 登录用户名
$mail->Password = "psw"; // 登录密码
$mail->From = "[email protected]"; // 发件人地址([email protected])
$mail->FromName = "发件人名称"; $mail->WordWrap = 50;
$mail->IsHTML(true); // 是否支持html邮件,true 或false
$mail->AddAddress("$client"); //客户邮箱地址
$mail->Subject = "标题";
$mail->Body = "文本内容";
if(!$mail->Send()){
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
return FALSE;
}
return TRUE;
}
//方法调用
$client = "[email protected]";
SendMailToClient($client);出状况你就用debug调试.