Home arrow LAMP Articles arrow PHP Articles arrow How to send mail from local windows box using PHP?
Sunday, 05 September 2010
How to send mail from local windows box using PHP? PDF Print E-mail
Written by Administrator   
Friday, 04 June 2010

Pre-requisites: XAMPP  version which includes the sendmail program.

Following example will work fine with XAMPP 1.7.3 release. Please follow the steps below:

STEP 1
Go to php.ini and uncomment following line:
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

STEP 2

1. Go to folder: C:\xampp\sendmail

2. Open sendmail.ini

3.Add following lines:
# A freemail service
account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from <username>@gmail.com
auth on
user <username>@gmail.com
password <your gmail password>

4. Edit following line at end:
# Set a default account
account default : Gmail

STEP 3

Restart Apache Server

STEP 4
Make test file sendMail.php :

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
if(mail('<username>@<someDomain>.com', 'My Subject', $message))
    echo "Mail sent successfully";
?>

STEP 5

Run sendMail.php in browser e.g. http://localhost/sendMail.php

STEP 6

Check mail at <username>@<someDomain>.com

Last Updated ( Saturday, 05 June 2010 )
 
Next >
Design by spook.68
This site is developed and maintained by softwebsolutionsindia.com