-1

我用 SMTPClient 类邮件 utf-8 发帖,但我什么也没做!请帮助我得到谢谢

class SMTPClient
{

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{

$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;

$this->subject = $subject;
$this->body = $body;


if ($SmtpPort == "") 
{
$this->PortSMTP = 25;
    }else{
$this->PortSMTP = $SmtpPort;
}


}

///////////////////////////////////////////////////////////////////////
$to = $_POST['to'];
$from =$_POST['from'];
$subject = $_POST['sub'];
$body = $_POST['message'];
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();

我在这里找到了这段代码:http: //url.lid.ir/KPyhfU

4

2 回答 2

0

我找到了!终于我找到了!添加代码非常容易:

$this->subject = "=?UTF-8?B?" . base64_encode(html_entity_decode($this->subject, ENT_COMPAT, 'UTF-8')) . "?=".$subject; 
于 2013-05-15T05:15:43.053 回答
0

更改 SMTPClient 中 SendMail 方法的定义

function SendMail ($charset = "utf-8", $contentType = "text/plain")
{
    if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) 
    {
        fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n"); 
        $talk["hello"] = fgets ( $SMTPIN, 1024 ); 
        fputs($SMTPIN, "auth login\r\n");
        $talk["res"]=fgets($SMTPIN,1024);
        fputs($SMTPIN, $this->SmtpUser."\r\n");
        $talk["user"]=fgets($SMTPIN,1024);
        fputs($SMTPIN, $this->SmtpPass."\r\n");
        $talk["pass"]=fgets($SMTPIN,256);
        fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n"); 
        $talk["From"] = fgets ( $SMTPIN, 1024 ); 
        fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n"); 
        $talk["To"] = fgets ($SMTPIN, 1024); 
        fputs($SMTPIN, "DATA\r\n");
        $talk["data"]=fgets( $SMTPIN,1024 );
        fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n".
        "Content-Type: ".$contentType."; ".$charset."\r\n\r\n".$this->body."\r\n.\r\n");
        $talk["send"]=fgets($SMTPIN,256);
        //CLOSE CONNECTION AND EXIT ... 
        fputs ($SMTPIN, "QUIT\r\n"); 
        fclose($SMTPIN);
    }
    return $talk;
} 
于 2013-05-14T15:19:10.870 回答