emails.php 673 B

1234567891011121314151617181920
  1. <?php
  2. require_once(realpath(dirname(__FILE__)).'/config.php');
  3. require_once(PATH_PHP.'database.php');
  4. require_once(PATH_PHP.'security.php');
  5. require_once(PATH_PHP.'user.php');
  6. function sendMail($template,$subject,$to=null,$from=null,$context=Array()){
  7. if(is_null($to)){
  8. $to = get('email');
  9. }
  10. if(is_null($from)){
  11. $from = get('email');
  12. }
  13. if(file_exists(PATH_DATA."/emails/{$template}.template")){
  14. $message = vsprintf(file_get_contents(PATH_DATA."/emails/{$template}.template"),$context);
  15. return @mail($to,$subject,$message,"From: {$from}\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n");
  16. }else{
  17. return false;
  18. }
  19. }
  20. ?>