The easiest way to start developing in PHP is to get XAMPP, the whole package can even be placed in a flash drive. Using the free AOL Mail account also allows you to sign in to the SMTP server without TLS which allows XAMPP sendmail to work.

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:xampplite, so your configuration may be a little different. The files to be modified are sendmail.ini and php.ini.

1. Finding a mail host that allows non-secured connection

Previously I wrote a guide on How to use sendmail in XAMPP for Windows but some people have difficulties successfully sending out an email with their web hosts. There is nothing particularly wrong with the guide. It is because XAMPP’s sendmail is compiled without TLS options. TLS (Transport Layer Security) is the successor of SSL that is required by some mail servers for authentication. Hotmail, which just launched POP3, requires you to use TLS for example. If you are thinking of Gmail, you’re out of luck too.

AOL Mail allows non-secure authentication which means we don’t need to recompile sendmail. This guide therefore uses AOL Mail. Sign up for a free AOL Mail account.

2. Modify your sendmail.ini

Your sendmail.ini should be located in C:xampplitesendmailsendmail.ini. You only need to be concern with 4 variables here:HUGOMORE42

  1. smtp_server
  2. smtp_port
  3. auth_username
  4. auth_password

Get them filled in, feel in your own username and password. Username is your AOL Mail email account, an example would be ‘justrealized_kahwee@aol.com’. That is not my email by the way. Remember the SMTP port is 587.

[code lang=“bash”]smtp_server=smtp.aol.com

smtp_port=587

auth_username=justrealized_kahwee@aol.com

auth_password=dp2hsn12[/code]

3. Modify your php.ini

XAMPP places the php.ini inside C:xamppliteapachebinphp.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:xampplitesendmailsendmail.exe -t”[/code]

And that’s all. Now for some testing. AOL mail requires you to use your AOL Mail email as the from_email, so I’ll be using ‘justrealized_kahwee@aol.com’.

[ad#highlight]

3. Let’s test it out

[code lang=“php”]<?php $from_name = “Justrealized”; $from_email = “justrealized_kahwee@aol.com”; $headers = “From: $from_name <$from_email>“;

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

$subject = “Test mail from Justrealized”;

$to = “somewhere@justrealized.com”;

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

echo “success!”;

} else {

echo “fail…”;

}

?>

[/code]

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