×
×
Sent Mail in PHP Using PHPMailer
Sent Mail in PHP Using PHPMailer
Published Aug 20,2020 by Kailash Singh
2 Comments 2239 Views
In this tutorial, we are going to learn about how to sent mail using PHP Mailer in PHP.
PHPMailer is perhaps the most popular open-source PHP library to send emails with.
Step 1 :- You need to use PHP Mailer Library
Click here to get PHP Mailer Library
Step 2 :- Create index file (index.php).
<?php
require('PHPMailer/phpmailer/PHPMailerAutoload.php'); // Here i am providing PHP Mailer Library path
$mail = new PHPMailer();
$mail->Host = 'smtp.gmail.com';
$mail->Port = '587';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = '[email protected]'; // Add Gmail ID Here
$mail->Password = '123456'; // Add Gmail Password Here
$mail->setFrom('[email protected]','This is testing'); // Here add your Email ID & Subject
$mail->addAddress('[email protected]'); // Here add User Email ID
$mail->addReplyTo('[email protected]'); // Here add your Email ID. Where user can send email
$mail->isHTML(true);
$mail->Subject = 'This is only testing'; // This is subject of Email
$name = "Kailash";
$phone = '7017277899';
$email = '[email protected]';
$msg = "Name: $name";
$msg .= "<br>";
$msg .= "Mobile: $phone";
$msg .= "<br>";
$mail->Body = "$msg";
if(!$mail->send())
{
echo "Message could not be sent!";
}
else{
echo "Message could be sent!";
}
?>
Result:
Hope this will help our developers.
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date
Copyright 2018 - 2024 Elevenstech Web Tutorials All rights reserved.