Source for file NS_SMTP_Service_Handler.php
Documentation is available at NS_SMTP_Service_Handler.php
* nanoserv handlers - SMTP server
* Copyright (C) 2004-2010 Vincent Negrier aka. sIX <six@aegis-corp.org>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
* Require the line input connection handler
require_once "nanoserv-compat/handlers/NS_Line_Input_Connection_Handler.php";
* SMTP Service handler class
* SMTP Service Handler constructor
$this->Write("200 ". $this->hostname. " SMTP ". (static::SERVER_STRING ? static::SERVER_STRING : "nanoserv/2.1.1-dev"). "\n");
if (strpos($updata, "HELO") === 0) {
} else if (strpos($updata, "MAIL FROM") === 0) {
} else if (strpos($updata, "RCPT TO") === 0) {
$this->Write("250 ". $rcpt. "... Recipient ok\n");
} else if (strpos($updata, "DATA") === 0) {
$this->Write("354 Enter mail, end with '.' on a line by itself\n");
} else if (strpos($updata, "QUIT") === 0) {
$this->Write("251 ". $this->hostname. " closing connection\n", array($this, "Disconnect"));
if (rtrim($data) !== ".") {
$this->Write("250 Message accepted\n");
$this->Write("554 Message rejected\n");
* Event called on SMTP HELO reception
* Extend this method to return the boolean status of the session (false = disconnect client)
* @param string $data remote HELO message
* Event called on SMTP MAIL FROM reception
* Extend this method to return the boolean status of the session (false = disconnect client)
* @param string $data remote MAIL FROM message
* Event called on SMTP RCPT TO reception
* Extend this method to return the boolean status of the session (false = disconnect client)
* @param string $data remote RCPT TO message
* Event called on unknown SMTP command reception
* Extend this method to return the boolean status of the session (false = disconnect client)
* @param string $data entire command line
$this->Write("500 Unknown command : '$data'\n");
* Event called on mail reception
* if true is returned, a "message accepted" reply will be sent, and "message rejected" for false
* @param string $env_from
* @param string $data this includes mail headers and content
public function on_Mail($env_from, $env_to, $data) {
|