Advertisement
Guest User

Untitled

a guest
Sep 18th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. $headers .= "Content-Type: text/html; charset=UTF-8rn";
  2.  
  3. <?php
  4. $dbhost = 'localhost';
  5. $dbuser = '###';
  6. $dbpass = '###';
  7. $dbname = '###';
  8.  
  9. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  10. if(!$conn) {
  11. die('Failed to connect to server: ' . mysql_error());
  12. }
  13. mysql_select_db($dbname);
  14.  
  15. $sql="SELECT Insured_Name,Expiry_Date FROM transactions
  16. WHERE MONTH(Expiry_Date) = MONTH(CURDATE()) and YEAR(Expiry_Date) = YEAR(CURDATE())";
  17. $result = mysql_query($sql)or die("Cannot query orders_products data" . mysql_error());
  18.  
  19.  
  20.  
  21. $email = "###############";
  22. $emailto = "############";
  23. $subject = "List of policies to expire this month";
  24. $headers .= "MIME-Version: 1.0rn";
  25. $headers .= "Content-Type: text/html; charset=UTF-8rn";
  26.  
  27. $headers = "From: $email";
  28.  
  29. // prepare email body text
  30. $body .= "Here Are A List Of policies to expire this monthnn";
  31. $body .= "<a href='expired.php'>Download complete list</a>nn";
  32. $body .='<table width="200" border="1">';
  33. $body .='<tr>';
  34. $body .='<td>Insured name</td>';
  35. $body .='<td>Expiry date</td>';
  36. $body .='</tr>';
  37.  
  38.  
  39. while($row=mysql_fetch_array($result)) {
  40. $body .='<tr>';
  41. $body .='<td>'.$row['Insured_Name'] .'</td>';
  42. $body .='<td>'.$row['Expiry_Date'] .'</td>';
  43.  
  44. $body .='</tr>';
  45.  
  46. }
  47. $body .='</table>';
  48. $body .= "This is an automated mail from the KBL insurance portalnn";
  49. // send email
  50. $send = mail($emailto, $subject, $body, $headers);
  51.  
  52. mysql_close($conn);
  53.  
  54. // redirect to success page
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement