简体   繁体   中英

Php SMTP Mail sending works only local

I'm trying since hours now to get a mailscript working on a live server. It works as intended on my localhost.

I'm using exact the same external SMTP server, the same PHP sources and the same databasetables too. The PHP version and MySQL version online and localhost are identical.

I tested everything. Everything works as pretended without the physical sending process. It doesn't send (or receive) email. I also went to the systemadministrator to let him check if there are any emails blocked or internal server errors, but here also everything fine.

I really tried everything I could think of but I didn't find the problem. Has anybody an idea what I could try next?

This is how the function for the physical sending looks like:

private function sendPhysical($sReciepient) {
    if ($oSmtpIn = fsockopen(SMTPSERVER, SMTPPORT)) {
        fputs($oSmtpIn, "EHLO " . SMTPSERVER . "\r\n");
        $aCodes["hello"] = fgets($oSmtpIn, 1024);

        fputs($oSmtpIn, "auth login\r\n");
        $aCodes["res"] = fgets($oSmtpIn, 1024);

        fputs($oSmtpIn, $this->encodeUser() . "\r\n");
        $aCodes["user"] = fgets($oSmtpIn, 1024);

        fputs($oSmtpIn, $this->encodePassword() . "\r\n");
        $aCodes["pass"] = fgets($oSmtpIn, 256);

        fputs($oSmtpIn, "MAIL FROM: <" . $this->sFrom . ">\r\n");
        $aCodes["From"] = fgets($oSmtpIn, 1024);

        fputs($oSmtpIn, "RCPT TO: <" . $sReciepient . ">\r\n");
        $aCodes["To"] = fgets($oSmtpIn, 1024);

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

        fputs($oSmtpIn, $this->generateHeader($sReciepient) . "\r\n\r\n" . $this->returnCompiledTemplate() . "\r\n.\r\n");
        $aCodes["send"] = fgets($oSmtpIn, 256);

        fputs($oSmtpIn, "QUIT\r\n");
        fclose($oSmtpIn);
    } else {
        $aCodes["connection"] = false;
    }
    return $aCodes;
}

Anybody a possible solution? I'm totally confused because it works at localhost and it already worked at the online server until last week...

看到这段代码有什么问题也很棘手,但是如果您不想通过php发送邮件有很多麻烦,请尝试使用PHPMailer。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM