Setting Up Apache HTTPD PHP Webserver with hMailServer
#hMailServer #PHP #Self-Hosted #ApacheHTTPD
Full steps can be found at https://i12bretro.github.io/tutorials/0016.html
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
--------------------------------------------------------------------
01. Open the Start Menu ≫ hMailServer ≫ hMailServer Administrator
02. Select localhost ≫ Click Connect
03. Login with the password set during the installation
04. Expand Settings ≫ Advanced ≫ IP Ranges
05. Click the Add... button
06. 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
07. Uncheck POP3 and IMAP from the Allow connections options
08. Uncheck Require SSL/TLS for authentication
09. 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
--------------------------------------------------------------------
01. Navigate to the PHP installation directory and open php.ini in a text editor
02. Search for SMTP
03. 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
05. Select File ≫ Save
06. Restart the Apache or IIS service
--------------------------------------------------------------------
Testing PHP Mail() Call
--------------------------------------------------------------------
01. Open a text editor
02. Create a PHP file with the following code
≪?php $to = 'i12bretro@i12bretro.local'; $subject = 'HTML E-Mail from PHP'; $body = '≪html≫≪head≫≪title≫HTML E-Mail≪/title≫≪/head≫≪body≫≪h3≫Check out my other tutorials at ≪a href="https://youtube.com/channel/UCNmLR_9Ec8NydshHNPnC5Jw"≫https://youtube.com/channel/UCNmLR_9Ec8NydshHNPnC5Jw≪/a≫≪/h3≫≪/body≫≪/html≫'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; $headers[] = 'From: PHP Webserver ≪system@i12bretro.local≫'; mail($to, $subject, $body, implode("\r\n", $headers)); ?≫
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro