< Browse > Home / Php / Blog article: Send email with PHP and GMail hosted for your domain

| Mobile | RSS

Send email with PHP and GMail hosted for your domain

November 29th, 2008 | 1 Comment | Posted in Php
kiran.tangudu

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.

Leave a Reply 508 views, 2 so far today |
  • No Related Post
Follow Discussion

One Response to “Send email with PHP and GMail hosted for your domain”

  1. admin admin Says:

    Thanks, Nice one

Leave a Reply

You must be logged in to post a comment.