用户未使用SMTP通过脚本接收电子邮件

时间:2015-12-14 11:02:38

标签: php email smtp

我有一个通过SMTP发送电子邮件的脚本,但是当我发送任何电子邮件时,我都没有收到该电子邮件。它以前工作,但从昨天起它不再工作了。每当我使用此脚本发送任何邮件时,它都表示已发送电子邮件,但当我查看我的电子邮件时,未收到该电子邮件。

$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $cc, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();

的config.php

$SmtpServer="mail.12two.com";
$SmtpPort=26;
$SmtpUser="noreply@12two.com";
$SmtpPass="**********";
$noreplyMail = "noreply@12two.com";

class.php

class SMTPClient
{

    function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $cc, $subject, $body)
    {
        $this->SmtpServer = $SmtpServer;
        $this->SmtpUser = base64_encode ($SmtpUser);
        $this->SmtpPass = base64_encode ($SmtpPass);
        $this->from = $from;
        $this->to = $to;
        $this->cc = $cc;

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

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

    function SendMail ()
    {
        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, "RCPT CC: <".$this->cc.">\r\n");
            $talk["cc"] = fgets ($SMTPIN, 1024);

            fputs($SMTPIN, "DATA\r\n");
            $talk["data"]=fgets( $SMTPIN,1024 );

            fputs($SMTPIN, "To: <".$this->to.">\r\nCc: <".$this->cc.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\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;
    }
}

0 个答案:

没有答案