Previous Next

Steps : 

1. Download the MAIL.ZIP File
2. Extract it to the location where you want to execute. (in  XAMPP, the location should be "htdocs" folder)
3. Execute the "index.php" in browser.

Description: 

Below is the main file which perform the main role
sendingmail.php :
<?php

date_default_timezone_set('Etc/UTC');
require './PHPMailer/PHPMailerAutoload.php';

$subject = $_POST["subject"];
$to = $_POST["to"];
$body = $_POST["body"];

$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure ='ssl';                 // type ssl or tpl
$mail->Host = "smtp.gmail.com";        
$mail->Port = 465;                           //Set the SMTP port number - 587 for authenticated TLS
$mail->IsHTML(true);
$mail->Username = "codevites@gmail.com";  // type sender mail here
$mail->Password = "Password234";               // type password
$mail->SetFrom("codevites@gmail.com");      // again type sender mail here
$mail->Subject = $subject;                // type subject here
$mail->Body = $body;                      // type body here
$mail->addAddress($to);                   // $to should have receiver mail

if($mail->Send()){                            // at this line mail will be sent
    echo "<html><body><center><br/><br/><br/><h3><b><i><span style='color:#22B'>Message HasBeen Sent Successfully</span></i></b></h3></center></body></html>";
}else{
    echo "Sorry there is an Error ".$mail->ErrorInfo;
}
     
?>

Previous Next