PHPMailer Sending Emails using PHP Code

php Programming

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.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Snippet Contents

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.

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


Related FAQ

Here are some more FAQ related to this Article:

  1.   AngularJS Arrays - tips, tricks and examples
  2.   Laravel 6 Show images from storage folder
  3.   Create Contact Form Sending Email via SMTP PHPMailer
  4.   Ajax Autocomplete Search using jQuery with PHP MySQLi
  5.   Google API Line Chart with JSON PHP & Mysql
  6.   PHP Codeigniter URL Routing Automatically
  7.   How To Create Contact Form With PHPMailer To Send Mails
  8.   php - SMTP Send mail using PHPMailer PHP Contact Form
  9.   Image Zoom In Zoom Out using JQuery
  10.   Create Dynamic Image Slider using PHP with jQuery

Leave a Reply

Your email address will not be published. Required fields are marked *