28 October 2008

How to Run PHP Mail Application in Your Local Computer

As a web programmer, sometimes you need to test an application that correlate with email. During the time, this application must be online, because it can't run in your local computer or localhost, even you have already setup your local computer as a web server.

Fortunately, there are some software can help you to run an application that correlate with email in your local computer. One of them is ArGoSoft Mail Server (agsmail.exe), a little size freeware. You can download at http://www.argosoft.com/rootpages/download.aspx

To setup the Argosoft Mail Server, just follow these simple steps:

  • Install the Argosoft Mail Server in your local computer. If done restart your computer
  • Run the Argosoft Mail Server
  • At Tools menu, choose Option and click on it
  • Type “localhost” in the textbox, click the Add button and then click OK
  • Now, at Tools menu, choose User and click on it
  • Click the “Add New User” button
  • In User Properties window, fill the User Name, your Real Name, Password, and Confirm your Password, for example: nopomawon, Yanis Rizaldi, secret, secret.
  • Click OK if you’re done. Now, you already have an email address: nopomawon@localhost

Test it with a simple PHP application.
Now is time to test your localhost mail server. PHP has a function that can be used to send an email, it’s easy to understand and the syntax is pretty simple:

mail(recipient, subject, message, additional header)


Let’s create a simple script to test your localhost mail server. Make sure the ArGoSoft Mail Server is active.

$recepient = “nopomawon@localhost”;
$subject = “Test an email”;
$message = “Test my localhost mail server”;
$from = “replay-to:
someone@domain.com”;

$send_mail = mail($recepient, $subject, $message, $from);

If ($send_mail)
{
Echo “successfully send email”;
}
Else
{
Echo “Oops!, can’t send the email”;
}



Run the scrip. If success, you can see the mail using Microsoft Outlook or Outlook Express. Of course, you must setup the mail program as same as ArGoSoft’s User Properties.
Display Name : Yanis Rizaldi
E-mail addres : nopomawon@localhost
Account name : nopomawon
Password : secret

That’s all, just try and have some fun

Good luck

No comments: