How to Send e-Mail using PHPMailer and Gmail SMTP

hello friends after a long time i’m going to post a simple yet useful post here about SMTP mails, i received few email requests from my readers to post email verification feature in my login and registration tutorial i’ll post email verification tutorial after this post this was first step to send emails from localhost and online server as well for that you have to use PHPMailer library, so take a quick a look at this tutorial to understand “how to send SMTP mails using PHPMailer

How to Send e-Mail using PHPMailer and Gmail SMTP

First of all download the PHPMailer library from this link :


copy-paste the following script using your editor and save this file as “sendmail.php” and try it in your localhost server


    $mail = new PHPMailer();
    $mail->CharSet =  "utf-8";
    $mail->SMTPAuth = true;
    $mail->Username = "[email protected]";
    $mail->Password = "your_gmail_password";
    $mail->SMTPSecure = "ssl";  
    $mail->Host = "";
    $mail->Port = "465";
    $mail->setFrom('[email protected]', 'your name');
    $mail->AddAddress('[email protected]', 'receivers name');
    $mail->Subject  =  'using PHPMailer';
    $mail->Body    = 'Hi there ,
                        <br />
                        this mail was sent using PHPMailer...
                        <br />
                        cheers... :)';
        echo "Message was Successfully Send :)";
        echo "Mail Error - >".$mail->ErrorInfo;

That’s it
here using this simple script you can send emails, try it in your localhost server, but make sure that you are connected to the internet