public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
         self::$_instance->init();
     }
     return self::$_instance;
 }
Example #2
0
}
handleSMTPLog('START: ' . date('c'));
handleSMTPResponse('220 clearhealth.local ESMTP');
$email = '';
$loadingData = false;
while ($data = fgets(STDIN)) {
    $data = str_replace("\r\n", "\n", $data);
    $data = str_replace("\n\r", "\n", $data);
    $data = str_replace("\r", "\n", $data);
    handleSMTPLog($data);
    if (preg_match('/^QUIT.*/', $data)) {
        handleSMTPResponse('221 clearhealth.local');
        file_put_contents('/tmp/email.log', $email, FILE_APPEND);
        $tmpFile = tempnam('/tmp', 'ch30_email_');
        file_put_contents($tmpFile, $email . "\n\n\n\n");
        $handler = HandleInboundMessages::getInstance();
        $handler->process($tmpFile);
        exit;
    }
    $fullStop = preg_match('/^\\.$/', $data);
    if ($loadingData && $fullStop) {
        handleSMTPResponse('250 ok 1251934559 qp 9841');
        handleSMTPLog('250 Ok: queued');
        $loadingData = false;
        $data = '';
    } else {
        if (!($loadingData && !$fullStop)) {
            if (preg_match('/^DATA.*/', $data)) {
                handleSMTPResponse('354 End data with <CR><LF>.<CR><LF>');
                handleSMTPLog('354 end data');
                $loadingData = true;