fix: Update patient_tracker.php (#6595)
[openemr.git] / interface / batchcom / batchEmail.php
blob3d13ae483f2273ab016eddeaa12e0ec1c75cf2e2
1 <?php
3 /**
4 * Batch Email processor, included from batchcom
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author cfapress
9 * @author Jason 'Toolbox' Oettinger <jason@oettinger.email>
10 * @copyright Copyright (c) 2008 cfapress
11 * @copyright Copyright (c) 2017 Jason 'Toolbox' Oettinger <jason@oettinger.email>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 // create file header.
16 // menu for fields could be added in the future
17 require_once("../globals.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
23 CsrfUtils::csrfNotVerified();
27 <html>
28 <head>
29 <title><?php echo xlt('Email Notification Report'); ?></title>
30 <?php Header::setupHeader(); ?>
31 </head>
32 <body class="body_top container">
33 <header class="row">
34 <?php require_once("batch_navigation.php");?>
35 <h1 class="col-md-12">
36 <a href="batchcom.php"><?php echo xlt('Batch Communication Tool')?></a>
37 <small><?php echo xlt('Email Notification Report'); ?></small>
38 </h1>
39 </header>
40 <main class="row mx-4">
41 <ul class="col-md-12">
42 <?php
43 $email_sender = $_POST['email_sender'];
44 $sent_by = $_SESSION['authUserID'];
46 while ($row = sqlFetchArray($res)) {
47 // prepare text for ***NAME*** tag
48 $pt_name = $row['title'] . ' ' . $row['fname'] . ' ' . $row['lname'];
49 $pt_email = $row['email'];
51 $email_subject = $_POST['email_subject'];
52 $email_body = $_POST['email_body'];
53 $email_subject = preg_replace('/\*{3}NAME\*{3}/', $pt_name, $email_subject);
54 $email_body = preg_replace('/\*{3}NAME\*{3}/', $pt_name, $email_body);
56 $headers = "MIME-Version: 1.0\r\n";
57 $headers .= "To: $pt_name<" . $pt_email . ">\r\n";
58 $headers .= "From: <" . $email_sender . ">\r\n";
59 $headers .= "Reply-to: <" . $email_sender . ">\r\n";
60 $headers .= "X-Priority: 3\r\n";
61 $headers .= "X-Mailer: PHP mailer\r\n";
62 if (mail($pt_email, $email_subject, $email_body, $headers)) {
63 echo "<li>" . xlt('Email sent to') . ": " . text($pt_name) . " , " . text($pt_email) . "</li>";
64 } else {
65 $m_error = true;
66 $m_error_count++;
70 </ul>
71 <?php
72 if ($m_error) {
73 echo '<div class="alert alert-danger">' . xlt('Could not send email due to a server problem.') . ' ' . text($m_error_count) . ' ' . xlt('emails not sent') . '</div>';
76 </main>
77 </body>
78 </html>