As a development machine without a dedicated IP or domain - for example a laptop, it is desirable to have a mail server so that web applications and software with mail features can be tested properly.

There are various alternative solutions to a mail server. For example sSMTP or Msmtp which act as smarthost relays but are not full-blown server daemons. They are great solutions but for our purposes we just want a simple mail server that is listening to port 25 so as to replicate as close as possible a real production environment.

Run exim-config to configure Exim to suit your needs. The default settings are good enough and you can install Exim as a Windows service.

Exim will be running on localhost at port 25. Simply send an email over port 25 at localhost and you should receive the email at the intended address. Check your trash or spam to make sure the email doesn’t get diverted.

Example


Here is an example mail sent via PHP script to a gmail address.

1. php.ini [mail section]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = your_name@gmail.com
2. testmail.php script that sends the mail
$to = "a_different_name@gmail.com";
$subject = "test mail";
$body = "This is just a test mail - kodiva.";

if (mail($to, $subject, $body)) {
    echo 'mail sent...';
}
Run testmail.php from your browser and check your email account for "a_different_name@gmail.com" to see if you received the message. Sometimes it takes a few minutes before the message will appear in your gmail inbox, the delay which we assume are due to possible spam checks.



Write a Comment


Your Name:
Your Email:
Comment: