MailHog is an email testing tool for developers.

It gives the developer the option to intercept and inspect the emails sent by his application.

You can download the MailHog Window's client from one of the links below.

The only configurations necessary for Apache are located into the php.ini

Set them like this:

smtp_port = 1025
sendmail_path = \path\to\mailhog.exe sendmail

Where \path\to\ is the path you have placed the downloaded MailHog exe file.
Ex.: C:\mailhog\mailhog.exe

For more information and support visit the MailHog GitHub page.

You can use the code below to test your MailHog configuration

  1. Start mailhog.exe (or however else you named the downloaded script)
  2. Visit http://localhost:8025/
  3. Put the following code into a php file and open it in localhost. (after configuring MailHog).
if(isset($_POST["mail"], $_POST["subject"], $_POST["email"], $_POST["myemail"])){

    $data       = array();
    $boundary 	= md5( uniqid() . microtime() );

    $from      	= strip_tags($_POST["myemail"]);
    $to      	= strip_tags($_POST["email"]);
    $subject 	= strip_tags($_POST["subject"]);
    $message	= $_POST["mail"];

    // Plain text version of message
    $body = "--$boundary" .PHP_EOL .
       "Content-Type: text/plain; charset=utf-8".PHP_EOL .
       "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL;
    $body .= chunk_split( base64_encode( strip_tags($message) ) );

    // HTML version of message
    $body .= "--$boundary". PHP_EOL .
       "Content-Type: text/html; charset=utf-8". PHP_EOL .
       "Content-Transfer-Encoding: base64". PHP_EOL . PHP_EOL ;
    $message ='<!DOCTYPE html>
                    <meta charset="UTF-8" />
                    <meta name="viewport" content="width=device-width, initial-scale=1" />
                    <title>MailHog email example</title>
    $body .= chunk_split( base64_encode( $message ) );
    $body .= "--$boundary";

    $headers = 'From: Ignatios <'.$from.'>'.PHP_EOL;
    $headers.= 'Reply-To: Ignatios <'.$from.'>'.PHP_EOL;
    $headers.= 'CC: '.$from.''.PHP_EOL;
    $headers.= 'MIME-Version: 1.0'.PHP_EOL;
    $headers.= 'Content-Type: multipart/alternative;boundary="'.$boundary.'"'.PHP_EOL;

    if(mail($to, $subject, $body, $headers)){
        $data["success"] = true;
        $data["text"] 	 = "Mail was sent successfully.";
        $data["success"] = false;
        $data["text"] = "Mail was not sent.";
?><!DOCTYPE html>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>MailHog email example</title>
        <link href=""
                type="text/css" rel="stylesheet" />
        <div class="container">
            <h2>Send an email for MailHog to Catch it.</h2>
            <form onsubmit="sendmail(event)" id="myForm" action="#" method="post">
                <div class="form-group">
                    <label for="myemail">Email From</label>
                    <input type="email" class="form-control" value=""
                        name="myemail" placeholder="Email sender" id="myemail" required />
                <div class="form-group">
                    <label for="email">Email to</label>
                    <input type="email" class="form-control" value=""
                        name="email" placeholder="Email recipient" id="email" required />
                <div class="form-group">
                    <label for="subject">Subject</label>
                    <input type="text" class="form-control" value="Test email"
                        name="subject" placeholder="Subject" id="subject" required />
                <div class="form-group" id="help-parent">
                    <label for="mail">Email Body</label>
                    <textarea name="mail" class="form-control" id="mail" rows="5" required>
                        <h1>Sent from localhost!</h1>
                    <span id="response" class="help-block"></span>
                <button type="submit" class="btn btn-info">Send Mail</button>
            function sendmail(event){
                var mail = document.getElementById("mail").value;
                var email = document.getElementById("email").value;
                var myemail = document.getElementById("myemail").value;
                var subject = document.getElementById("subject").value;
                const toSend = {
                    method : 'post',
                    headers: {
                      "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
                    body : "email="+encodeURIComponent(email)+
                fetch('<?=$_SERVER["REQUEST_URI"]?>', toSend)
                .then(function(response) {
                    return response.json();
                .then(function(data) {
                    document.getElementById("response").innerHTML = data.text;
                    alert("The request resulted in an error.");