Setting Up Apache HTTPD PHP Webserver with hMailServer 🌱

PHP cannot perform SMTP authentication natively using the mail() function. The way I set up my development server is to allow unauthenticated SMTP emails to be sent from the PHP webhost IP address on a non-standard port

Creating a Webhost SMTP Account

  1. Open the Start Menu > hMailServer > hMailServer Administrator
  2. Select localhost > Click Connect
  3. Login with the password set during the installation
  4. Expand Settings > Advanced > IP Ranges
  5. Click the Add... button
  6. Enter PHP Webserver as the Name, set I priority above 50 and enter the PHP Webserver IP in the Lower and Upper IP address fields
  7. Uncheck POP3 and IMAP from the Allow connections options
  8. Uncheck Require SSL/TLS for authentication
  9. Uncheck all boxes under Require SMTP authentication
  10. Click the Save button
  11. Expand Settings > Advanced > TCP/IP Ports
  12. Click the Add... button
  13. Select SMTP from the Protocol dropdown
  14. Enter a non-standard SMTP port (8025) for PHP to communicate on
  15. Set Connection security to None
  16. Click the Save button
  17. Click Yes to restart the hMailServer service

Configuring PHP SMTP Server

  1. Navigate to the PHP installation directory and open php.ini in a text editor
  2. Search for SMTP
  3. Update the following parameters
    SMTP = smtp.i12bretro.local
    smtp_port = 8025
    Optionally, set the mail.log to a file path for logging or syslog to log to the event viewer
    • NOTE: If using SSL the certificate authority needs to be trusted by PHP. This can be setup by adding the CA and intermediate CA certs to a .pem file and setting the curl.cainfo value in php.ini
  4. Select File > Save
  5. Restart the Apache or IIS service

Testing PHP Mail() Call

  1. Open a text editor
  2. Create a PHP file with the following code