They use an email server, obviously. PHP, or any other server side scripts are used to process and inteprate commands from the user, such as getting the email address, subjects and the content of the email. MySQL, or any other database software, are simply to keep a record of all it's members of the email service, just like keep your member information, password and userID in the Hotmail or Gmail database.
You too, can make your own email server with simple server software. However, because it is simple, most email servers might block emails sent from your server or throw your messages into the Junk folder. I've tried while Hotmail didn't receive the message, and Gmail throws it as a Spam mail. Basically, I think, that your server is not recognised by the email industry list, such that many email providers used that to prevent anonymous emails that could be potential spam or junk mail.
Anyway, just to let you have a clearer picture of how email servers work, download a email server program and install to your computer to try that out. Practical lessons are always better than theory, so do some hands on yourself..
Step 1Here are some email servers that I use.
I use least 2 servers, multi-thread together before. To do it, you would have to read on their documents.
http://www.sendmail.org/http://www.mailenable.com/http://www.argosoft.com/rootpages/MailServer/Default.aspxStep 2Download the PHP scripts to send your email from a webpage.
This is a very common PHP script which you can get support almost anywhere, even here in Trap17.
http://phpmailer.sourceforge.net/http://www.phpfreaks.com/tutorials/130/0.php (Guide to PHPMailer)
Step 3Remember to change the server variable in the PHP script to 'localhost' to use the email server installed on your computer. This variable can also be set to use a foreign email server. Hotmail used to provide public access to their server, hence you could put the Hotmail mail server domain here. However, since the anti-spam technology was introduced, many email providers had stopped giving access to public for using their SMTP server.
CODE
$mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
Change to:
CODE
$mail->Host = "localhost"; // SMTP servers
Step 4Launch your PHPmailer script on your browser to run the application.
Enjoy exploring..

Reply