191 lines
5.3 KiB
PHP
191 lines
5.3 KiB
PHP
|
<?php
|
||
|
include_once("includes/config/config.php");
|
||
|
include_once("includes/functions.php");
|
||
|
include_once("log_entry.php");
|
||
|
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
|
||
|
|
||
|
// Import PHPMailer classes into the global namespace
|
||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||
|
use PHPMailer\PHPMailer\Exception;
|
||
|
|
||
|
require 'src/Exception.php';
|
||
|
require 'src/PHPMailer.php';
|
||
|
require 'src/SMTP.php';
|
||
|
$mail = new PHPMailer;
|
||
|
error_log("email_sender");
|
||
|
?>
|
||
|
<?
|
||
|
$from="manoj.dubey@tvsmotor.com";
|
||
|
$mail->isSMTP(); // Set mailer to use SMTP
|
||
|
$mail->Host = $configArray['email_host']; // Specify main and backup SMTP servers
|
||
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||
|
$mail->Username = $from ; // SMTP username
|
||
|
//$mail->Password = $configArray['email_password']; // SMTP password
|
||
|
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||
|
$mail->Port = $configArray['email_port']; // TCP port to connect to
|
||
|
$mail->isHTML(true);
|
||
|
|
||
|
// Sender info
|
||
|
$mail->setFrom($from, 'OHC');
|
||
|
$mail->addReplyTo($from, 'OHC');
|
||
|
|
||
|
|
||
|
//$from=$configArray['email_username'];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$subject = "Test Email";
|
||
|
$ccList = "manojdubeyonline@gmail.com";
|
||
|
$mail_content = "<body>
|
||
|
<p>Thank you for your interest to our OHCTECH-Occupational Health Software and Solutions. We will soon connect and share details as per the details shared by you.</p>
|
||
|
<p>Regards, </p><p>OHCTECH TEAM</p></body></html>";
|
||
|
$toList = "manoj@ohctech.com,manoj@techsyneric.com";
|
||
|
|
||
|
|
||
|
function send_mail($toList, $ccList, $subject, $messageBody, $remarks)
|
||
|
{
|
||
|
error_log("email_sender send_mail");
|
||
|
error_log("toList:" . $toList);
|
||
|
error_log("ccList:" . $ccList);
|
||
|
error_log("subject:" . $subject);
|
||
|
error_log("mail_content:" . $messageBody);
|
||
|
|
||
|
$mail = new PHPMailer;
|
||
|
|
||
|
|
||
|
/*$mail_data = explode(',',$str_dat);
|
||
|
//unset("info@ohctech.com");
|
||
|
$mail->SMTPDebug = 2; //enable debugging if failure
|
||
|
$mail->isSMTP(); // Set mailer to use SMTP
|
||
|
$mail->Host = "mail.ohctech.com"; // Specify main and backup SMTP servers
|
||
|
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||
|
$mail->Username = "info@ohctech.com"; // SMTP username
|
||
|
$mail->Password = "Tikora@1234"; // SMTP password
|
||
|
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||
|
$mail->Port ="587"; // TCP port to connect to
|
||
|
$mail->isHTML(true);
|
||
|
|
||
|
// Sender info
|
||
|
$mail->setFrom("info@ohctech.com", 'OHC');
|
||
|
$mail->addReplyTo("info@ohctech.com", 'OHC');
|
||
|
|
||
|
$from="info@ohctech.com";
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
$from="manoj.dubey@tvsmotor.com";
|
||
|
$host ="cust81834-s.out.mailcontrol.com";
|
||
|
|
||
|
|
||
|
|
||
|
$headers = "From: OHCTECH\r\n";
|
||
|
$headers .= "MIME-Version: 1.0\r\n";
|
||
|
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
|
||
|
|
||
|
$mail_content = "Welcome to OHC. Your OTP to verify Your Email ID is";
|
||
|
$toList = str_replace(' ', ',', $toList);
|
||
|
$toList = str_replace(';', ',', $toList);
|
||
|
|
||
|
$ccList = str_replace(' ', ',', $ccList);
|
||
|
$ccList = str_replace(';', ',', $ccList);
|
||
|
|
||
|
|
||
|
$toList_arr = preg_split("/\,/", $toList);
|
||
|
$ccList_arr = preg_split("/\,/", $ccList);
|
||
|
try {
|
||
|
$mail->isSMTP(); // Set mailer to use SMTP
|
||
|
$mail->SMTPDebug = 2;
|
||
|
$mail->Host = $host;//getConfigKey('email_host'); // Specify main and backup SMTP servers
|
||
|
$mail->SMTPAuth = false; // Enable SMTP authentication
|
||
|
$mail->Username = $from; // SMTP username
|
||
|
// $mail->Password = getConfigKey('email_password'); // SMTP password
|
||
|
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||
|
$mail->Port = 25;//getConfigKey('email_port'); // TCP port to connect to
|
||
|
$mail->isHTML(true);
|
||
|
|
||
|
// Sender info
|
||
|
$mail->setFrom($from, 'OHC');
|
||
|
$mail->addReplyTo($from, 'OHC');
|
||
|
|
||
|
foreach ($toList_arr as $toaddr) {
|
||
|
$mail->addAddress($toaddr);
|
||
|
}
|
||
|
foreach ($ccList_arr as $ccaddr) {
|
||
|
$mail->addCC($ccaddr);
|
||
|
}
|
||
|
|
||
|
$style = "<style>
|
||
|
body{
|
||
|
font-size:12px;
|
||
|
}
|
||
|
.table {
|
||
|
width: 100%;
|
||
|
margin-bottom: 1rem;
|
||
|
color: #212529;
|
||
|
background-color: transparent;
|
||
|
}
|
||
|
|
||
|
.table th,
|
||
|
.table td {
|
||
|
padding: 0.75rem;
|
||
|
vertical-align: top;
|
||
|
border-top: 1px solid #dee2e6;
|
||
|
}
|
||
|
|
||
|
.table thead th {
|
||
|
vertical-align: bottom;
|
||
|
border-bottom: 1px solid #dee2e6;
|
||
|
}
|
||
|
|
||
|
.table tbody + tbody {
|
||
|
border-top: 1px solid #dee2e6;
|
||
|
}
|
||
|
|
||
|
.table-sm th,
|
||
|
.table-sm td {
|
||
|
padding: 0.3rem;
|
||
|
}
|
||
|
|
||
|
.table-bordered {
|
||
|
border: 1px solid #dee2e6;
|
||
|
text-align:center;
|
||
|
}
|
||
|
|
||
|
.table-bordered th,
|
||
|
.table-bordered td {
|
||
|
border: 1px solid #dee2e6;
|
||
|
}
|
||
|
|
||
|
.table-bordered thead th,
|
||
|
.table-bordered thead td {
|
||
|
border-bottom-width: 2px;
|
||
|
}
|
||
|
</style>";
|
||
|
|
||
|
$mail->Subject = $subject;
|
||
|
$mail->Body = $style . $messageBody . $remarks;
|
||
|
|
||
|
error_log("email_sender done settings");
|
||
|
|
||
|
if (!$mail->send()) {
|
||
|
echo "Message could not be sent. Mailer Error: " . $mail->ErrorInfo;
|
||
|
error_log('Message could not be sent. Mailer Error: ' . $mail->ErrorInfo);
|
||
|
} else {
|
||
|
echo "Message has been sent";
|
||
|
error_log("Message has been sent");
|
||
|
}
|
||
|
error_log('Message has been sent.');
|
||
|
} catch (phpmailerException $e) {
|
||
|
echo $e->errorMessage(); //Pretty error messages from PHPMailer
|
||
|
} catch (Exception $e) {
|
||
|
echo $e->getMessage(); //Boring error messages from anything else!
|
||
|
}
|
||
|
}
|
||
|
send_mail($toList, $ccList, $subject,$mail_content,'');
|
||
|
|
||
|
?>
|
||
|
|