The easiest way to start developing in PHP is to get XAMPP, the whole package can even be placed in a flash drive.

0. Objective

To get your PHP scripts to send an email out. This guide assumes you have XAMPP or XAMPP Lite. My environment is Windows Vista. (I use XAMPP Lite by the way)

My XAMPP is placed in C:xampp, so your configuration may be a little different. The files to be modified are sendmail.ini and php.ini.

1. Modify your sendmail.ini

Your sendmail.ini should be located in C:xamppsendmailsendmail.ini. You only need to be concern with 3 variables here:

  1. smtp_server
  2. auth_username
  3. auth_password

Get them filled in, an example would be as follows:



Most SMTP servers require authentication. I just setup an email through my Media Temple account. (By the way, is hosted by Media Temple, if you’re interested in their service and would be kind enough, consider quoting ‘RYNSE.COM’ without quotes as your referrer. This would give me a bit of discount for my yearly subscriptions. Thanks.)

2. Modify your php.ini

XAMPP places the php.ini inside C:xamppapachebinphp.ini. You can open the file and do a search for ‘sendmail_path’. It’s at line 704 for me. You can simply uncomment that line.

[code]sendmail_path = “C:xamppsendmailsendmail.exe -t”[/code]

And that’s all. Now for some testing.


3. Let’s test it out

[code lang=“php”]<?php $from_name = “Justrealized”; $from_email = “”; $headers = “From: $from_name <$from_email>“;

$body = “Hi, nThis is a test mail from $from_name <$from_email>.“;

$subject = “Test mail from Justrealized”;

$to = “”;

if (mail($to, $subject, $body, $headers)) {

echo “success!”;

} else {

echo “fail…”;




Execute those codes and you should receive something in your inbox. Here’s what I see in Gmail:

And you get this in Gmail

Hope it works for you. Please correct me if I missed out anything.

(Those aren’t my email, if you sent emails there your emails will get sucked into some blackhole.)

comments powered by Disqus