PHPMailer Sending Emails using PHP Code

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.


//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->Host = '';
    $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]', 'Jaydeep');
    $send_mail->addAddress('[email protected]', 'Pakainfo');
    $send_mail->addAddress('[email protected]');
    $send_mail->addReplyTo('[email protected]', 'noreply');
    $send_mail->addCC('[email protected]');
    $send_mail->addBCC('[email protected]');
    //PHP Files Attachments
    $send_mail->Subject = 'Wel-come To & Test Mail Subject!';
    $send_mail->Body    = 'Latest Body of simple Pakainfo is SMTP Email Testing demo';
    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

Angular 6 CRUD Operations Application Tutorials

Read :


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 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.