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