Language support added JH
[openemr.git] / interface / batchcom / batchEmail.php
blob440ea28966e28abf8ef4ac8e2131429d5371dbe3
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 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
13 <link rel=stylesheet href="batchcom.css" type="text/css">
14 </head>
15 <body <?echo $top_bg_line;?> topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
16 <span class="title"><?xl('Batch Communication Tool','e')?></span>
17 <br><br>
20 $email_sender=$_POST['email_sender'];
21 $sent_by=$_SESSION["authId"];
22 $msg_type="xl('Email from Batchcom')";
24 while ($row=sqlFetchArray($res)) {
26 // prepare text for ***NAME*** tag
27 $pt_name=$row['title'].' '.$row['fname'].' '.$row['lname'];
28 $pt_email=$row['email'];
29 $email_subject=$_POST['email_subject'];
30 $email_body=$_POST['email_body'];
31 $email_subject=ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_subject );
32 $email_body= ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_body );
34 $headers = "MIME-Version: 1.0\r\n";
35 $headers .= "To: $pt_name<$pt_email>\r\n";
36 $headers .= "From: <$email_sender>\r\n";
37 $headers .= "Reply-to: <$email_sender>\r\n";
38 $headers .= "X-Priority: 3\r\n";
39 $headers .= "X-Mailer: PHP mailer\r\n";
41 if ( mail ('',$email_subject,$email_body,$headers)) {
43 echo ("<br>Email sent to $pt_name at $pt_email");
44 $patient_id=$row['id'];
45 register_email($patient_id, $sent_by, $msg_type, $email_subject, $email_body );
47 } else {
48 $m_error=TRUE;
49 $m_error_count++;
54 if ($m_error) {
55 echo ("xl('Could not send email due to a server problem, ','','<br>). $m_error_count . xl(' emails not sent','','','<br>')");
58 ?>