other features added
[openemr.git] / interface / batchcom / batchEmail.php
blob2c88e88132284b6579ed4412aa8dd324fcd88a37
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">Batch Communication Tool</span>
17 <br><br>
20 $email_sender=$_POST['email_sender'];
22 while ($row=sqlFetchArray($res)) {
24 // prepare text for ***NAME*** tag
25 $pt_name=$row['title'].' '.$row['fname'].' '.$row['lname'];
26 $pt_email=$row['email'];
27 $email_subject=$_POST['email_subject'];
28 $email_body=$_POST['email_body'];
29 $email_subject=ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_subject );
30 $email_body= ereg_replace('\*{3}NAME\*{3}', $pt_name, $email_body );
32 $headers = "MIME-Version: 1.0\r\n";
33 $headers .= "To: $pt_name<$pt_email>\r\n";
34 $headers .= "From: <$email_sender>\r\n";
35 $headers .= "Reply-to: <$email_sender>\r\n";
36 $headers .= "X-Priority: 3\r\n";
37 $headers .= "X-Mailer: PHP mailer\r\n";
39 if ( mail ('',$email_subject,$email_body,$headers)) {
41 echo ("<br>Email sent to $pt_name at $pt_email");
43 } else {
44 $m_error=TRUE;
45 $m_error_count++;
50 if ($m_error) {
51 echo ("<br>Could not send email due to a server problem, $m_error_count emails not sent<br>");
54 ?>