这是我写的方法请你们看一 看缺少什么
header("content-type:text/html; charset=utf-8");
function send_mail($name, $email, $subject, $content, $type = 0, $notification = false) {
global $smarty, $db, $config, $itac;
include_once ('yuyang/class.phpmailer.php');
$mail = new PHPMailer(); //建立邮件发送类
$mail->IsSMTP(); // 使用SMTP方式发送
$config['smtp_mail']="smtp.163.com";
$mail->Host = $config['smtp_mail']; // 您的企业邮局域名
$mail->SMTPAuth = true; // 启用SMTP验证功能
$config['smtp_user']="[email protected]";
$config['smtp_pass']='邮箱密码';
$mail->Username = $config['smtp_user']; // 邮局用户名(请填写完整的email地址)
$mail->Password = $config['smtp_pass']; // 邮局密码*/$mail->From = $config['smtp_user']; //邮件发送者email地址
$mail->FromName = "=?utf-8?B?" . base64_encode($config['title']) . "?=";
$mail->AddAddress($email, "$name"); //收件人地址,可以替换成任何想要接收邮件的email信箱,格式是
$mail->IsHTML(true);
$mail->Subject = "=?utf-8?B?" . base64_encode($subject) . "?=";
$mail->Body = $content; //邮件内容// var_dump($mail);
if (!$mail->Send()) {
return $mail->ErrorInfo;
}
return true;
}
send_mail("于洋","[email protected]","注册信息",'有没有传说');

解决方案 »

  1.   

    在构建email的时候,email里也应该有header的信息。
    这个类没用过,另外,也不知道接收到的数据是什么内容,没法具体分析。
      

  2.   

    发邮件的时候一定要加入编码,这是我写的一个mail类的send方法,你可以参考一下.
    如有需要我可以把我的mail类直接发给你.Function Send($email_to, $email_subject, $email_message, $email_from = ''){
    global $PHPCMS;
    $email_subject = '=?utf-8?B?'.base64_encode(str_replace("\r", '', $email_subject)).'?=';
    $email_message = str_replace("\r\n.", " \r\n..", str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $email_message)))));
    $email_from = $email_from == '' ? '=?utf-8?B?'.base64_encode(BLK_SysName)."?= <".BLK_SysMail.">" : (preg_match('/^(.+?) \<(.+?)\>$/',$email_from, $from) ? '=?utf-8?B?'.base64_encode($from[1])."?= <$from[2]>" : $email_from);
    $emails = explode(',', $email_to);
    Foreach($emails as $touser){
    $tousers[] = preg_match('/^(.+?) \<(.+?)\>$/',$touser, $to) ? ($this->mailusername ? '=?utf-8?B?'.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;
    }
    $email_to = implode(',', $tousers);
    $headers = "MIME-Version: 1.0\r\nTo: {$email_to}\r\nFrom: {$email_from}<{$email_from}>\r\nX-Priority: 3\r\nX-Mailer: BlackHand \r\nDate: ".date("r")."\r\nContent-type: text/html; charset=UTF-8\r\n"; IF($this->type == 1){
    Return $this->smtp($email_to, $email_subject, $email_message, $email_from, $headers);
    }ElseIF($this->type == 2){
    Return @mail($email_to, $email_subject, $email_message, $headers);
    }Else{
    ini_set('SMTP', $this->server);
    ini_set('smtp_port', $this->port);
    ini_set('sendmail_from', $email_from);
    Return @mail($email_to, $email_subject, $email_message, $headers);
    }
    }
      

  3.   

    首先看看你的东西在本页面是不是乱码。如果不是乱码。一般邮件的都是GBK的。所以如果你的页面的编码是utf-8的,发送到邮件后的字也会乱码的
      

  4.   

    很简单,你只需要统一编码为gb2312,比如你也没事utf8的,那么你发送邮件前,需要将发送的标题和内容,转码为gb2312,iconv("UTF-8","GBK",发送的内容);