Posted By

kubi on 04/03/08


Tagged

class php mail


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamesming


Mail Class


 / Published in: PHP
 

  1. <?php
  2. $_SESSION[next_send] = 0;
  3.  
  4. define (HEADER, 'From: Messag via web <[email protected]>' . "
  5. " .'X-Mailer: PHP');
  6. define (RECIPIENT,'[email protected]');
  7. define (SUBJECT,'This is a subject');
  8. define (REFERER,'www.domain.de');
  9. define (REDIRECT,'http://www.domain.de');
  10. define (TIMETOWAIT, '30');
  11. define (CODE,'4815162342');
  12.  
  13. // DO NOT EDIT ANYTHING AFTER THIS !!! //
  14.  
  15. class MyMailer
  16. {
  17. private $postdata = null;
  18. private $message = null;
  19.  
  20. public function __construct($post)
  21. {
  22. if (REFERER == $_SERVER['HTTP_HOST'] && CODE == $post['code'])
  23. {
  24. $this->handleMessage($post);
  25. }
  26. else
  27. {
  28. echo "there is something wrong!";
  29. exit();
  30. }
  31. }
  32.  
  33. private function handleMessage($post)
  34. {
  35. foreach ($post as $key => $value)
  36. {
  37. if (!preg_match ("#", $value))
  38. {
  39. $this->message .= $key." : ".strip_tags(trim($value))."\n";
  40. }
  41. }
  42. $this->sendMail();
  43. }
  44.  
  45. private function sendMail()
  46. {
  47. if (time() >= $_SESSION[next_send])
  48. {
  49. mail(RECIPIENT, SUBJECT, $this->message, HEADER);
  50. $_SESSION['next_send'] = time()+TIMETOWAIT;
  51. }
  52. }
  53. }
  54. $mail = new MyMailer($_POST);
  55.  
  56. header('Location: '.REDIRECT);
  57. exit();
  58. ?>

Report this snippet  

You need to login to post a comment.