Implement PHP mailer with smtp authentication
This tutorial is for implementing the PHP mailer with SMTP authentication. You can set SMTP authentication mail to your website using this. So simply follow the setup, and you can get working SMTP authentication mail.
Step 1)
Download the PHP mailer library from here. click here for download
Step 2)
Make a function for sending mail as below.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/Exception.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = ''; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = "";
$mail->Password = "";
$mail->SMTPSecure = 'tls'; // Enable SSL encryption, TLS also accepted with port 465
$mail->Port = 587; // TCP port to connect to
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
//Recipients
$mail->setFrom('Your SMTP Email Address', 'Your SMTP User Name'); //This is the email your form sends From
$mail->addAddress('Your User Email Address', 'Your User Name'); // Add a recipient address
//Content
//$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Your Subject';
$htmldata = "<html>
<head>
<title>Title Here</title>
</head>
<body>HTML Content</body></html>";
$mail->IsHTML(true);
$mail->Body = $htmldata;
$mail->send(); echo 'Message has been sent';
} catch (Exception $e) { echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
Step 3)
Now use the above function to send the SMTP authentication mail via SMTP.
Thank you a bunch for sharing this with all people you really understand what you are speaking about! Bookmarked. Please also consult with my site =). We will have a hyperlink change agreement among us
I am sure this article has touched all the internet users, its really really good article on building up new webpage.
Well I truly liked studying it. This article procured by you is very practical for accurate planning.
I am sure this piece of writing has touched all the internet visitors, its really really fastidious paragraph on building up new weblog.
I’ll immediately grab your rss as I can not to find your e-mail subscription link or e-newsletter service. Do you have any? Kindly permit me recognize so that I may just subscribe. Thanks.
I am sure this article has touched all the internet people, its really really good article on building up new blog.
I am sure this piece of writing has touched all the internet visitors, its really really pleasant post on building up new web site.
I’ll immediately seize your rss as I can not in finding your email subscription hyperlink or newsletter service. Do you’ve any? Please permit me realize in order that I could subscribe. Thanks.
Very quickly this web page will be famous amid all blog users, due to it’s fastidious posts
Thanks for finally writing about >Cognitive Treatment For Depression And Anxiety – Canadian RX Meds Blog <Loved it!
I am not rattling superb with English but I get hold this very leisurely to translate.
I will right away seize your rss as I can not find your email subscription link or e-newsletter service. Do you have any? Kindly permit me realize in order that I may subscribe. Thanks.
I really like what you guys are up too. This kind of clever work and reporting! Keep up the fantastic works guys I’ve included you guys to my blogroll.
I am sure this post has touched all the internet viewers, its really really nice post on building up new blog.
I’ll right away clutch your rss as I can not to find your email subscription hyperlink or newsletter service. Do you’ve any? Please let me realize in order that I may just subscribe. Thanks.
Ahaa, its nice discussion concerning this article at this place at this web site, I have read all that, so at this time me also commenting at this place.
Hi there Dear, are you genuinely visiting this web page daily, if so after that you will definitely take fastidious experience.
Some genuinely great articles on this web site, regards for contribution.
Hi there, I check your blog regularly. Your story-telling style is awesome, keep doing what you’re doing!
I am sure this article has touched all the internet people, its really really good article on building up new weblog.
These are in fact wonderful ideas in regarding blogging. You have touched some pleasant factors here. Any way keep up wrinting.
This is a topic which is near to my heart… Cheers! Exactly where are your contact details though?
I simply could not depart your site prior to suggesting that I actually enjoyed the usual info an individual supply on your guests? Is gonna be back steadily in order to investigate cross-check new posts
My brother suggested I may like this blog. He was once totally right. This post actually made my day. You cann’t imagine simply how a lot time I had spent for this info! Thank you!
You made some decent points there. I looked on the web to learn more about the issue and found most people will go along with your views on this site.
**back biome**
Backbiome is a naturally crafted, research-backed daily supplement formulated to gently relieve back tension and soothe sciatic discomfort.