File: /var/www/html/sarvodayahospital/public/services/behealthy/online-doctor-consultation/send-mail.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require('PHPMailer/src/Exception.php');
require('PHPMailer/src/PHPMailer.php');
require('PHPMailer/src/SMTP.php');
function sendMail($pagename = '', $name = '', $mobile = '', $email = '', $message = '')
{
$mail = new PHPMailer;
$mail->isSMTP(); // using SMTP protocol
$mail->Host = 'smtp3.netcore.co.in'; // SMTP host as gmail
$mail->SMTPAuth = true; // enable smtp authentication
$mail->Username = 'connect@sarvodayahospital.com'; // sender gmail host
$mail->Password = '#Way2Cloud@12!'; // sender gmail host password
$mail->SMTPSecure = 'TLS'; // for encrypted connection
$mail->Port = 587; // port for SMTP
$mail->setFrom('connect@sarvodayahospital.com','Sarvodaya Hospital');
/* Add a recipient */
$mail->addAddress('connect@sarvodayahospital.com');
/* Email subject */
$mail->Subject = 'Inquiry From '.$pagename;
/* Set email format to HTML */
$mail->isHTML(true);
/* Email body content */
if($pagename != null && $name != null && $mobile != null && $email != null && $message != null){
$mailContent = "
<h2>Lead Details- Sarvodaya <span style='color:green'>$pagename</span> Leads</h2>
<hr style='width: 120px;height: 3px;margin-top: -0.5rem; background: green; border-radius: 5px; float: left;margin-left: 12%;'>
<table style='width:50%;border: 1px solid black; margin-top:30px;'>
<tr style='border: 1px solid black;'>
<th>Page:</th>
<td style='border: 1px solid black; padding: 5px; text-align: center;'>$pagename</td>
</tr>
<tr style='border: 1px solid black;'>
<th>Name:</th>
<td style='border: 1px solid black; padding: 5px; text-align: center;'>$name</td>
</tr>
<tr style='border: 1px solid black;'>
<th>Phone:</th>
<td style='border: 1px solid black; padding: 5px; text-align: center;'>$mobile</td>
</tr>
<tr style='border: 1px solid black;'>
<th>Email:</th>
<td style='border: 1px solid black; padding: 5px; text-align: center;'>$email</td>
</tr>
<tr style='border: 1px solid black;'>
<th>Message:</th>
<td style='border: 1px solid black; padding: 5px; text-align: center;'>$message</td>
</tr>
</table><br><br>
<a href='https://www.sarvodayahospital.com' style='text-align: center'>
<img src='https://www.sarvodayahospital.com/assets/images/sarvodaya-logoNew.png' alt='Sarvodaya Hospital Logo' style='width: 50%;
height: auto;'></a>";
}
$mail->Body = $mailContent;
/* Send email */
if(!$mail->send())
{
echo 'Mail could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'Mail Sent.';
return true;
}
}
// User Email id get and send mail for confirmation
function sendUserMail($email='', $name='')
{
$mail = new PHPMailer;
$mail->isSMTP(); // using SMTP protocol
$mail->Host = 'smtp3.netcore.co.in'; // SMTP host as gmail
$mail->SMTPAuth = true; // enable smtp authentication
$mail->Username = 'connect@sarvodayahospital.com'; // sender gmail host
$mail->Password = '#Way2Cloud@12!'; // sender gmail host password
$mail->SMTPSecure = 'tls'; // for encrypted connection
$mail->Port = 587; // port for SMTP
$mail->setFrom('connect@sarvodayahospital.com','Sarvodaya Hospital');
/* Add a recipient */
$mail->addAddress($email);
/* Email subject */
$mail->Subject = 'Sarvodaya Hospital Inquiry Confirmation';
/* Set email format to HTML */
$mail->isHTML(true);
/* Email body content */
if($email != null && $name != null ){
$mailContent = "
<h3>Dear $name ,</h3>
<p>Thank you for reaching out to us, we appreciate your interest in Sarvodaya Hospital!
</p>
<p>Your inquiry is important to us, and we are dedicated to provide you with all the relevant information you need.</p>
<p>However, If you have any additional queries, please feel free to contact at: 1800 313 1414</p>
<p>Warm Regards.</p>
<table>
<tr>
<th style='font-weight: bold; text-align: left;'>Sarvodaya Healhtcare!</th>
</tr>
<tr>
<td>Email: connect@sarvodayahospital.com</td>
</tr>
<tr>
<td>Toll Free: 1800 313 1414</td>
</tr>
</table>
<a href='https://www.sarvodayahospital.com'><img src='assets/images/sarvodaya-logoNew.png' alt='Sarvodaya Hospital Logo' style='width: 300px;
height: auto;'></a>";
}
else{
echo 'User email id could not be find.';
}
$mail->Body = $mailContent;
/* Send email */
if(!$mail->send())
{
echo 'Mail could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
echo 'Mail Sent.';
return true;
}
}
?>