0016.html 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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,E-Mail,Web Server,Administration,Tutorial,i12bretro,hMailServer,Self-Hosted">
  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. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  12. <script type="text/javascript" src="includes/js/steps.js"></script>
  13. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  14. </head>
  15. <body>
  16. <div id="gridContainer">
  17. <div class="topMargin"></div>
  18. <div id="listName" class="topMargin">
  19. <h1>Setting Up Apache HTTPD PHP Webserver with hMailServer</h1>
  20. </div>
  21. <div></div>
  22. <div id="content">
  23. <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>
  24. <h2>Creating a Webhost SMTP Account</h2>
  25. <ol>
  26. <li>Open the Start Menu &gt; hMailServer &gt; hMailServer Administrator</li>
  27. <li>Select localhost &gt; Click Connect</li>
  28. <li>Login with the password set during the installation</li>
  29. <li>Expand Settings &gt; Advanced &gt; IP Ranges</li>
  30. <li>Click the Add... button</li>
  31. <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>
  32. <li>Uncheck POP3 and IMAP from the Allow connections options</li>
  33. <li>Uncheck Require SSL/TLS for authentication</li>
  34. <li>Uncheck all boxes under Require SMTP authentication</li>
  35. <li>Click the Save button</li>
  36. <li>Expand Settings &gt; Advanced &gt; TCP/IP Ports</li>
  37. <li>Click the Add... button</li>
  38. <li>Select SMTP from the Protocol dropdown</li>
  39. <li>Enter a non-standard SMTP port (8025) for PHP to communicate on</li>
  40. <li>Set Connection security to None</li>
  41. <li>Click the Save button</li>
  42. <li>Click Yes to restart the hMailServer service</li>
  43. </ol>
  44. <h2>Configuring PHP SMTP Server</h2>
  45. <ol>
  46. <li>Navigate to the PHP installation directory and open php.ini in a text editor</li>
  47. <li>Search for SMTP</li>
  48. <li>Update the following parameters<br />
  49. SMTP = smtp.i12bretro.local<br />
  50. smtp_port = 8025<br />
  51. Optionally, set the mail.log to a file path for logging or syslog to log to the event viewer
  52. <ul>
  53. <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>
  54. </ul>
  55. </li>
  56. <li>Select File &gt; Save</li>
  57. <li>Restart the Apache or IIS service</li>
  58. </ol>
  59. <h2>Testing PHP Mail() Call</h2>
  60. <ol>
  61. <li>Open a text editor</li>
  62. <li>Create a PHP file with the following code<br />
  63. <textarea>&lt;?php
  64. $to = &#39;i12bretro@i12bretro.local&#39;;
  65. $subject = &#39;HTML E-Mail from PHP&#39;;
  66. $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;;
  67. $headers[] = &#39;Content-type: text/html; charset=iso-8859-1&#39;;
  68. $headers[] = &#39;From: PHP Webserver &lt;system@i12bretro.local&gt;&#39;;
  69. mail($to, $subject, $body, implode(&quot;\r\n&quot;, $headers));
  70. ?&gt;</textarea></li>
  71. </ol>
  72. </div>
  73. </div>
  74. </body>
  75. </html>