If you are using wamp in a windows machine,its quite hard to send mail through native php mail function or sendmail or SMTP.But you can use PHP Mailer program to send mail from localhost.It bypasses native mail,sendmail methods.It works well on windows as well as *nix machines.
Download PHP Mailer from http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/ or from http://phpmailer.worxware.com/
$mail = new PHPMailer();
$body="<b>This mail is sent using PHP Mailer</b>";#HTML tags can be included
$mail->SMTPAuth = true; #enable SMTP authentication
$mail->SMTPSecure = "ssl"; #sets the prefix to the server
$mail->Host = "smtp.gmail.com"; #sets GMAIL as the SMTP server
$mail->Port = 465; #set the SMTP port
$mail->Username = ""; #your gmail username
$mail->Password = ""; #Your gmail password
$mail->From = ""; #your gmail id
$mail->FromName = ""; #your name
$mail->Subject = "Subject of the mail";
$mail->WordWrap = 50;
$mail->AddAddress("recipient mail id","recipient name");
$mail->IsHTML(true); // send as HTML
echo "Mailer Error: " . $mail->ErrorInfo;
echo "Message has been sent";
You can also send mail with attachments.For more info refer the documentation of PHP Mailer.
Change SMTP Host,port,authentication only if sure of what you are doing.
When you install wamp, www will be the default folder to put your site and it will be accessed by http://localhost/site-name.But how can one run site that exists outside www folder.Here ‘s the simple solution
Create a folder in any one of your parititons.Here i have created a folder called trunk in C:\ drive.
- Right click the wamp icon click and go Apache->Alias directories->add an alias
A new command window will be opened
- Enter the only(without ant relative or absolute path) the name of the folder that you created and hit enter.
- Now specify the path where the folder is located and hit enter.
Thats it alias created.Site can be accessed with this url http://localhost/trunk.Store all the files in the folder that you created.