Send email with PHP and GMail hosted for your domain
Here we can find the steps for sending mail from local host using Phpgmailer class :
Step 1: Download the Phpgmailer supporting files using the below link :
http://www.vulgarisoip.com/files/phpgmailer.zip
Step 2: Please open the sendmail.ini file from XAMPp root directory, path would be somthing like
xampp\sendmail\sendmail.ini
in that file UN comment the following to lines and set them with an gmail user account name and password .
The lines would be like this :
;auth_username=’user@domain.com’
;auth_password=’password’
After UN commenting those they would be like :
auth_username=’user@domain.com’ // any gmail user account
auth_password=’password’ // gmail account password
Step 2: Extract the downloaded zip file into your project folder.
Step 3: Then use the following peace of code for sending mails from your local host it self with an internet connection
1.) require_once(’/phpgmailer/class.phpgmailer.php’); // this will include the phpgmailer class files
2.) $mail = new PHPGMailer(); // creates the object for class
3.) $mail->Username = ‘user@domain.com‘; // Probably this will be your gmail account user name . please create a
separate account for this purpose and use that one.
4.) $mail->Password = ‘password’; // The above accounts password.
5.) $mail->From = ‘user@domain.com‘; // This will be shown to the user from whom he is getting this particular mail
6.) $mail->FromName = ‘User Name’;
7.) $mail->Subject = ‘Subject’; // Mail subject.
8.) $mail->AddAddress(‘myfriend@domain.com‘); // To address
9.) $mail->Body = ‘Hey buddy, here’s an email!’; // actual message
10.) $mail->Send(); // Finally here we are sending the mail.
Note :
If there is any HTML tags in your Mail body then place the following peace of code before line number 9
$mail->IsHTML(true);
That’s all it over we can now send mail the mails from our local host itself.


November 29th, 2008 at 10:44 am
Thanks, Nice one