added date to oldEvt call
[openemr.git] / interface / batchcom / batchEmail.php
bloba3ea7cfc9d6860883875e0a5560c637c47ef8e69
1 <?php
2 /*
3 batch Email processor, included from batchcom
4 */
6 // create file header.
7 // menu for fields could be added in the future
9 ?>
10 <html>
11 <head>
12 <?php html_header_show();?>
13 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
14 <link rel="stylesheet" href="batchcom.css" type="text/css">
15 </head>
16 <body class="body_top">
17 <span class="title"><?php xl('Batch Communication Tool','e')?></span>
18 <br><br>
20 <?php
21 $email_sender=$_POST['email_sender'];
22 $sent_by=$_SESSION["authId"];
23 $msg_type=xl('Email from Batchcom');
25 while ($row=sqlFetchArray($res)) {
27 // prepare text for ***NAME*** tag
28 $pt_name=$row['title'].' '.$row['fname'].' '.$row['lname'];
29 $pt_email=$row['email'];
30 $email_subject=$_POST['email_subject'];
31 $email_body=$_POST['email_body'];
32 $email_subject=ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_subject );
33 $email_body= ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_body );
35 $headers = "MIME-Version: 1.0\r\n";
36 $headers .= "To: $pt_name<$pt_email>\r\n";
37 $headers .= "From: <$email_sender>\r\n";
38 $headers .= "Reply-to: <$email_sender>\r\n";
39 $headers .= "X-Priority: 3\r\n";
40 $headers .= "X-Mailer: PHP mailer\r\n";
42 if ( mail ('',$email_subject,$email_body,$headers)) {
44 echo ("<br>Email sent to $pt_name at $pt_email");
45 $patient_id=$row['id'];
46 register_email($patient_id, $sent_by, $msg_type, $email_subject, $email_body );
48 } else {
49 $m_error=TRUE;
50 $m_error_count++;
55 if ($m_error) {
56 echo ("xl('Could not send email due to a server problem, ','','<br>). $m_error_count . xl(' emails not sent','','','<br>')");
59 ?>