Tag Archives: email

Using PHP mail function on Localhost Only


If you are testing the PHP mail function mail( ) running from your own localhost and you do not what to run your own mail server this may help.

I was testing a PHP activation script that would send a email to another email to activate the new users account. My environment is all ran locally, and I had no desire to set-up a proper configure mail server or use Pear mail.

So to get around this problem I installed webmin so that I could easily access postfix mail server and to receive the email.

Install Webmin

Download webmin
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.340_all.deb

Install Webmin
sudo dpkg -i webmin_1.340_all.deb

Once installed you can log into webmin using your root password.

Now when sending the activation email insure that you send it to root@locahost, do not include .com or . anything as this did not work for me.

If you have any validation within your script make sure everything relation to email validation is changed.

Changing PHP validation (preg_match)

Normal Validation in php
(preg_match (‘/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/’,)

Changed Validation
(preg_match (‘/^[\w.-]+@[\w.-]/’,)

Once you do this you should be able to access the email via webmin within the postfix module. Goto servers, users mailbox, select root or your system user name.