Jump to content.

Guerrilla Mail – behind the scenes; Today our open source PHP SMTP server is released!

The technology behind Guerrilla Mail has undergone through a number of iterations in the last few years.

In the beginning, Guerrilla Mail was running the Exim mail server, and the emails were fetched using POP. This proved to be inefficient and unreliable, so the system was replaced in favor of piping the emails directly in to a PHP script.

Soon, the piping solution became a problem too; it required a new process to be started for each new email, and it also required a new database connection every time.

So, how did we eliminate this bottleneck? Conveniently, PHP has a socket library which means we can use PHP to program a simple and efficient SMTP server. (SMTP = Simple Mail Transfer Protocol)

If the server runs as a daemon (which is a never-terminating program), then the system doesn’t need to launch a new process for each incoming email.  Also, because Guerrilla Mail emails are deleted after 1 hour, our server doesn’t need to run and insane amount of checks for each connection (eg, NS Lookups, white-lists, black-lists, SPF domain keys, Spam Assassin, etc).

We only need to open a single database connection and a single process can be re-used indefinitely. The PHP server is able to multiplex simultaneous connections, and it can pass the email directly to the MySQL database as soon
as it is received.

So now we can receive, process and store email all in the one process and we only hit the disk when necessary.

The performance improvement has been dramatic.

Today, we release the source code to our server under open source!

Open source PHP SMTP server: https://github.com/flashmob/Guerrilla-SMTPd – we welcome other temporary email service sites to use our server.

The purpose of this daemon is to grab the email, save it to the database and disconnect as quickly as possible.

Only simple MIME processing of the email is performed:
– For each email, the header is parsed to determine if the email intended for the domains serviced. (You wouldn’t believe how many spammers do this!)
– For each email, the body of the email is identified, decoded and converted to UTF-8.