4 * Batch Email processor, included from batchcom
7 * @link http://www.open-emr.org
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();
29 <title
><?php
echo xlt('Email Notification Report'); ?
></title
>
30 <?php Header
::setupHeader(); ?
>
32 <body
class="body_top container">
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
>
40 <main
class="row mx-4">
41 <ul
class="col-md-12">
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>";
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>';