How to Send e-Mail using PHPMailer and Gmail SMTP


First of all download the PHPMailer library from this link : http://sourceforge.net/projects/phpmailer/

PHP CODE

<?php 

 require_once('class.phpmailer.php');
 
    $mail = new PHPMailer();
    $mail->CharSet =  "utf-8";
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Username = "your_mail@gmail.com";
    $mail->Password = "your_mail_password";
    $mail->SMTPSecure = "ssl";  
    $mail->Host = "smtp.gmail.com";
    $mail->Port = "465";
 
    $mail->setFrom('your_mail@gmail.com', 'your name');
    $mail->AddAddress('to_mail@mail.com', 'receivers name');
 
    $mail->Subject  =  'using PHPMailer';
    $mail->IsHTML(true);
    $mail->Body    = 'Hi there ,
                        <br />
                        this mail was sent using PHPMailer...
                        <br />
                        cheers... :)';
  
 if($mail->Send())
 {
  echo "Message was Successfully Send :)";
 }
 else
 {
  echo "Mail Error - >".$mail->ErrorInfo;
 } 
?>

if you have using other mail server like yahoo, bing, or your own domain mail id's replace the $mail->Username and $mail->Password with particular mail server information





Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.