| ronanchilvers.com |
|
PHPSMTPD is a simple SMTP server written in PHP5. It understands a reasonable subset of the SMTP language and is capable of receiving mail from scripts or client software. It understands SMTP AUTH commands for PLAIN and LOGIN mechanisms (LOGIN is the method primarily used by Microsoft email clients). It can be used as a test bed for email sending, becoming particularly useful when used to validate email scripts for web development. Access to a fully fledged email server is not required - PHPSMTPD will take its place during development work.
PHPSMTPD stores all email it receives into a spool folder in two files. One contains the raw source of the email as supplied during the DATA phase of the SMTP session. The second file contains all the meta information obtained during the SMTP session such as envelope sender, queue id, recipient addresses and so on. Both files are simple text files and can therefore be opened and examined easily.
SMTP AUTH requests always succeed. The authentication transaction needs to be correct but, by default, the request always succeeds. However a subclass could easily be written which would actually authenticate users, via the PHPSMTPD command hooks facility. Documentation for the command hooks and how to use them will appear here soon. In the meantime have a look at the myphpsmtpd subclass in the myphpsmtpd.php file.
In response to some comments on this project, here are some things that PHPSMTPD doesn't do and will never do.
It is NOT and will NEVER be...
NB: PHPSMTPD will NOT run on PHP 4.x. It uses both tcp streams and exceptions, neither of which are available in the version 4.x.
Installation of phpsmtpd is pretty straightforward. You need to unzip the archive somewhere, then create a spool directory in which mail will be stored. The spool directory can be anywhere. You might want to put it in the same folder as the main scripts or you might want to put it elsewhere. Once you have created it (wherever it is) you need to edit the config.php file. This file has 4 parameters in it.
This is the IP address you want PHPSMTPD to listen on. If you use 0.0.0.0, all available interfaces will be used
Default: 0.0.0.0
This is the port you want PHPSMTPD to listen on. It can be anyvalid port number, but remember that ports below 1024 require root privileges to use. I DO NOT recommend running PHPSMTPD with root privileges.
Default: 8500
This is the file you want php to log to. The path can be absolute or relative, in which case the path is taken relative to the location of the main script. You can actually use any value (for a local resource) that would be valid in a standard php fopen() call. See www.php.net/fopen for more details.
Default: php://stdout
This is the directory you want php to write received mail into. The spool directory can be anywhere and this parameter needs to be an absolute path.
Default: NONE