Today, We want to share with you PHPMailer Sending Emails using PHP Code.In this post we will show you php code to send email using smtp server, hear for Sending Emails in PHP with PHPMailer we will give you demo and example for implement.In this post, we will learn about Sending Emails using PHP with PHPMailer with an example.
PHPMailer Sending Emails using PHP Code
There are the Following The simple About PHPMailer Sending Emails using PHP Code Full Information With Example and source code.
As I will cover this Post with live Working example to develop send mail using phpmailer from localhost, so the send mail using smtp in php example for this example is following below.
sendMail.php
<?php //include PHP libs use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'vendor/autoload.php'; $send_mail = new PHPMailer(true); try { //PHP Simple Server settings $send_mail->SMTPDebug = 2; $send_mail->isSMTP(); $send_mail->Host = 'smtp.gmail.com'; $send_mail->SMTPAuth = true; $send_mail->Username = '[email protected]'; $send_mail->Password = 'set_here_my_password'; $send_mail->SMTPSecure = 'tls'; $send_mail->Port = 587; $send_mail->setFrom('[email protected]_name.com', 'Jaydeep'); $send_mail->addAddress('[email protected]_name.net', 'Pakainfo'); $send_mail->addAddress('[email protected]_name.com'); $send_mail->addReplyTo('[email protected]_name.com', 'noreply'); $send_mail->addCC('[email protected]_name.com'); $send_mail->addBCC('[email protected]_name.com'); //PHP Files Attachments $send_mail->addAttachment('/media/pakainfo_products.tar.gz'); //Content $send_mail->isHTML(true); $send_mail->Subject = 'Wel-come To Pakainfo.com & Test Mail Subject!'; $send_mail->Body = 'Latest Body of simple Pakainfo is SMTP Email Testing demo'; $send_mail->send(); echo 'Good Luck Your Message has been sent'; } catch (Exception $e) { echo 'Sorry Dear, Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; }
And last You access this web application using any browser like Mozila, chrome or any other with your main domain name following by any script name
http://mydomain_name.com/sendMail.php
Angular 6 CRUD Operations Application Tutorials
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about PHPMailer Sending Emails using PHP Code.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.