How To Send Smtp Mail By Gmail Account

smtp mail

how-to-send-smtp-mail-by-gmail :-

PHP developers use only PHP function mail() function. but, it does not Support All feature. But PHPMailer library provide us several ways of sending email: mail(), Sendmail, qmail & direct to SMTP servers. You can use any feature of SMTP-based e-mail, multiple recepients via to, CC, BCC, etc. In short: PHPMailer is an efficient way to send e-mail within PHP.


Now this tutorial We Learn How How To Send  Smtp Mail By Gmail Account

1. Allow less secure apps – On Yor Gmail Account

Login Yor Gmail Account and Click This link

Now use this Code

require 'main_lib/class.phpmailer.php';
require 'main_lib/class.smtp.php';
require 'main_lib/class.pop3.php';


$mail = new PHPMailer;
$mail->SMTPDebug = 3;   // Enable verbose debug output
$mail->Host = '';  
$mail->SMTPAuth = true;

$mail->Username =''; // SMTP username
$mail->Password = 'xxxxxx'// SMTP password

//user othentication end

$mail->SMTPSecure = 'ssl'; // Accept SSL/TLS
$mail->Port = 465// TCP port to connect to

//From email address

//sender email address


$mail->Debugoutput = 'html';
$mail->isHTML(true); // Set email format to HTML

$mail->Subject = 'subject';
$mail->Body    = 'body';

//for image template
$mail->Body    .= '<a href="" target="blank"><img alt="poster" src="cid:1001"></a>';

$filepath= "poster/Desert.jpg";
$filecid = 1001;
$filename= 'Desert.jpg';
$encoding = 'base64';
$mail->AddEmbeddedImage($filepath, $filecid, $filename, $encoding);
if(!$mail->send()) {

    return 'Message could not be sent Mailer Error: ' . $mail->ErrorInfo;
} else{
    echo"massage send";


Recommended Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Trusted by Ethereum Code Trading