<?php
// use PHP Mailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/Autoload.php';
$body="Enter Mail Body here";
// send email with create html body data
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing) 1 = errors and messages 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "ENTER HOSTNAME HERE"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "ENTER USERNAME HERE"; // GMAIL username
$mail->Password = "ENTER PASSWORD HERE"; // GMAIL password
$mail->SetFrom('ENTER FROM HERE', 'ENTER SENDER'S NAME HERE');
$mail->Subject = "ENTER SUBJECT HERE";
$mail->MsgHTML($body);
// add email addresses
$mail->AddAddress('ENTER TO HERE', 'NAME');
$mail->AddCC('ENTER CC HERE', 'NAME');
$mail->addAttachment('ATTACHMENT NAME.csv');
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
No comments:
Post a Comment
Thanks a lot for your valuable Comment!