send smtp mail by php

send smtp mail by php

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: PHP Mailer is an efficient way to send smtp mail by 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

https://myaccount.google.com/lesssecureapps

 

 

Now use this Code

<?php
//set_time_limit(0);
ini_set('max_execution_time',0);    
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->isSMTP();                                      
$mail->Host = 'smtp.gmail.com';  
$mail->SMTPAuth = true;

$mail->Username ='[email protected]'; // 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
$mail->SetFrom('[email protected]','name');

//sender email address
$mail->addAddress('[email protected]');


//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');

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

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

//for image template
/*
$mail->Body    .= 'poster';

$filepath= "poster/Desert.jpg";
$filecid = 1001;
$filename= 'Desert.jpg';
//Encoding
 
$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";
}

?>

  smileysmileysmileysmiley

Download Here

Previous Post

Total Coments (0)