0016.html 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Setting Up Apache HTTPD PHP Webserver with hMailServer</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="PHP Email Server Setup,PHP SMTP Configuration,PHP,Email,E-Mail,E-Mail Server,Apache HTTPD Configuration,Apache,Apache HTTPD,Web Server,Administration,HMailServer,Self-Hosted,HTTPD,Microsoft Windows,System Administrator,Apache HTTPD Administration,Apache HTTPD Config,Free E-Mail Server,Home Lab,Free Software,Free SMTP Server On Windows,Free And Easy SMTP Server,Self-hosted,Install Guide,Web Server Administration,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Setting Up Apache HTTPD PHP Webserver with hMailServer">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="03/25/2022 09:08:59 PM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Setting Up Apache HTTPD PHP Webserver with hMailServer</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <p>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</p>
  26. <h2>Creating a Webhost SMTP Account</h2>
  27. <ol>
  28. <li>Open the Start Menu &gt; hMailServer &gt; hMailServer Administrator</li>
  29. <li>Select localhost &gt; Click Connect</li>
  30. <li>Login with the password set during the installation</li>
  31. <li>Expand Settings &gt; Advanced &gt; IP Ranges</li>
  32. <li>Click the Add... button</li>
  33. <li>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</li>
  34. <li>Uncheck POP3 and IMAP from the Allow connections options</li>
  35. <li>Uncheck Require SSL/TLS for authentication</li>
  36. <li>Uncheck all boxes under Require SMTP authentication</li>
  37. <li>Click the Save button</li>
  38. <li>Expand Settings &gt; Advanced &gt; TCP/IP Ports</li>
  39. <li>Click the Add... button</li>
  40. <li>Select SMTP from the Protocol dropdown</li>
  41. <li>Enter a non-standard SMTP port (8025) for PHP to communicate on</li>
  42. <li>Set Connection security to None</li>
  43. <li>Click the Save button</li>
  44. <li>Click Yes to restart the hMailServer service</li>
  45. </ol>
  46. <h2>Configuring PHP SMTP Server</h2>
  47. <ol>
  48. <li>Navigate to the PHP installation directory and open php.ini in a text editor</li>
  49. <li>Search for SMTP</li>
  50. <li>Update the following parameters<br />
  51. SMTP = smtp.i12bretro.local<br />
  52. smtp_port = 8025<br />
  53. Optionally, set the mail.log to a file path for logging or syslog to log to the event viewer
  54. <ul>
  55. <li>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</li>
  56. </ul>
  57. </li>
  58. <li>Select File &gt; Save</li>
  59. <li>Restart the Apache or IIS service</li>
  60. </ol>
  61. <h2>Testing PHP Mail() Call</h2>
  62. <ol>
  63. <li>Open a text editor</li>
  64. <li>Create a PHP file with the following code<br />
  65. <textarea>&lt;?php
  66. $to = &#39;i12bretro@i12bretro.local&#39;;
  67. $subject = &#39;HTML E-Mail from PHP&#39;;
  68. $body = &#39;&lt;html&gt;&lt;head&gt;&lt;title&gt;HTML E-Mail&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h3&gt;Check out my other tutorials at &lt;a href=&quot;https://youtube.com/channel/UCNmLR_9Ec8NydshHNPnC5Jw&quot;&gt;https://youtube.com/channel/UCNmLR_9Ec8NydshHNPnC5Jw&lt;/a&gt;&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;&#39;;
  69. $headers[] = &#39;Content-type: text/html; charset=iso-8859-1&#39;;
  70. $headers[] = &#39;From: PHP Webserver &lt;system@i12bretro.local&gt;&#39;;
  71. mail($to, $subject, $body, implode(&quot;\r\n&quot;, $headers));
  72. ?&gt;</textarea></li>
  73. </ol>
  74. </div>
  75. </div>
  76. </body>
  77. </html>