PHP Send Email using SMTP Authentication

PHP Send Email using SMTP Authentication

Today, We want to share with you PHP Send Email using SMTP Authentication.
In this post we will show you Send Mail using SMTP in PHP Script, hear for send-e-mail-messages-via-smtp-with-phpmailer-and-gmail we will give you demo and example for implement.
In this post, we will learn about Send Email From a PHP Script Using SMTP Authentication with an example.

Why using GMail(Google) for sending mail messages(SMTP)?

First of all it’s FREE(SMTP Send mail)! Sure most website owners or business site can use their own SMTP server for sending email messages from their website, but it makes sense even than to use GMail(Google Product) for sending mail(SMTP). The chance is big that your websites IP address(reg ip) is on a blacklist(ip) if your site(blog or cms) is on hosted by a shared web hosting provider. If not or you host your blog or site on your own server, there is always a risk that your IP get blacklisted. Because of some limitations send email, the Enabled SMTP server from Google is a future with good choice web applications with less than at least 500 recipients per day, i am sure with check this information from the Google(offical) help pages.

Also Read :  Convert Byte Array to Image File C# and VB.Net

[code]
<?php
$timezone = "Asia/Kolkata";//initialize timezone using PHP
date_default_timezone_set($timezone); //set Default timezone using PHP
require 'class.phpmailer.php'; //include lib
$to = "[email protected]";

$subject = "Pakainfo.com services inquiry";
$fname="admin_ng";
$lname="king of ng";
$cellno="989856****";
$bname="Adverts Google Adsense";
$phone="9898******";
$email="[email protected]";
$address="9-ng road,surat.";
$message="Dear ".$fname;

$message .= "

ngforfree SERVICES

Pakainfo.com SERVICES

<tr

Your First Name is “.$fname.”
User Last Name get is : “.$lname.”
Verify Email address is “.$email.”
Cell Number “.$cellno.”
Current Phone Number is “.$phone.”
Business Name is verify here “.$bname.”
User Address Enabled is “.$address.”

kind Regards
Pakainfo.com,
ng-all SERVICES.

“;
$mail = new PHPMailer;
//init php SMTP mail
$mail->IsSMTP();
// Set mailer to use SMTP
//$mail->SMTPSecure = ‘tls’;
//$mail->SMTPSecure = ‘ssl’;
$mail->Host = ‘server.Pakainfo.com’;
// Your web email severe Specify main and backup server
$mail->Port = 465;
// if using ssl->465 and tls->443
// Set the SMTP port
$mail->SMTPDebug = 1;
// Here enables SMTP debug information (for testing)
// 1 = display errors and messages
// 2 = Show messages only
$mail->SMTPAuth = true;
//It’s boolean true or false
// Enable SMTP authentication
$mail->Username = ‘[email protected]’;
// SMTP username
$mail->Password = ‘*********’;
// SMTP password
$mail->SMTPSecure = ‘ssl’;
// there are two type tls and ssl Enable encryption, ‘ssl’ also accepted
$mail->From = ‘[email protected]’;
// from name
$mail->FromName = ‘pakainfo’;
$mail->AddAddress($to,’pakainfo’);

Also Read :  Monetized Videos not showing ads in youtube 2019 - Google Adsens

//Maile with attachments Provide file path and name of the attachments
$mail->addAttachment(“yourfile.txt”, “File.txt”); //file.txt
$mail->addAttachment(“images/profile_dreams.png”);
//Filename is optional it’s optional

$mail->IsHTML(true);
// Set email format to HTML

$mail->Subject = $subject;//Set subject
$mail->Body = $message; //set mail body

if(!$mail->Send()) {

//echo ‘does not send email with Mailer Error: ‘ . $mail->ErrorInfo;
header(“Location: main_index.html”);

}
else
{
header(“Location: thankyou_page.html”);
}

?>
[/php]

Recommended For You.

Laravel 5.7 Stripe Payment Gateway Example From Scratch
Today, We want to share with you Laravel 5.7 Stripe Payment Gateway Example From Scratch.In this post we will show

Add a Comment

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