Setting up PHPMailer with Office365 SMTP using php

Setting up PHPMailer with Office365 SMTP using php

In this post we will show you Setting up PHPMailer with Office365 SMTP using php, hear for Setting up PHPMailer with Office365 SMTP using php we will give you demo and example for implement.

Setting up PHPMailer with Office365 SMTP using php port and server
Setting up PHPMailer with Office365 SMTP using php port and server

From PHPMailer GitHub site, follow “Minimal installation” section and download class.phpmailer.php and class.smtp.php.

Send email on App Service using Office 365

it is a Proof of Concept to send email using the PHP Mailer library and Office 365. Copy-paste the code from “A Simple Example” section or use the following:

// include it
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$Office365_mail = new PHPMailer(true);

$Office365_mail->IsSMTP();
$Office365_mail->SMTPAuth = true;

$Office365_mail->Host = "smtp.office365.com";
$Office365_mail->Port = 25; // or 587
// $Office365_mail->SMTPSecure = 'tls'; // if Port is 587
$Office365_mail->Username = "add-your-email@onlinecode";
$Office365_mail->Password = "Add@My@Password";

// Typical mail data

$Office365_mail->AddAddress("add-your-email@onlinecode", "onlinecode org");
$Office365_mail->SetFrom("noreply@onlinecode", "onlinecode org");
$Office365_mail->Subject = "Add Your Subject";
$Office365_mail->Body    = "This is the HTML message body For <b>Setting up PHPMailer with Office365 SMTP using php</b>";
$Office365_mail->AltBody = "This is the with out HTML message For Setting up PHPMailer with Office365 using SMTP";

try
{
$Office365_mail->Send();
echo "Setting up PHPMailer with Office365 SMTP using php Success!";
}
catch(Exception $exception)
{
echo "<pre>";
var_dump($exception);
echo "</pre>";
//Something went bad
echo "PHPMailer with Office365 Fail :: " . $Office365_mail->ErrorInfo;
}

Hope this code and post will helped you for implement Setting up PHPMailer with SMTP Office365 using php. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

Leave a Comment

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

2  +  5  =  

We accept paid advance and paid guest Posting on our Site : Contact US