简体   繁体   English

PHP SMTP邮件发送仅在本地有效

[英]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. 我使用的是完全相同的外部SMTP服务器,相同的PHP源和相同的数据库表。 The PHP version and MySQL version online and localhost are identical. 在线和本地主机的PHP版本和MySQL版本相同。

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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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