Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Checkmail.class.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. class Checkmail {
  3. private $config = null;
  4. private $mbox = null;
  5. private $email_list = [];
  6. function __construct($cofig) {
  7. $this->config = $cofig;
  8. }
  9. public function openImap() {
  10. $this->mbox = imap_open($this->config['settings']['imap']['connection'].'INBOX', $this->config['settings']['smtp']['username'], $this->config['settings']['smtp']['password']);
  11. }
  12. public function closeImap() {
  13. imap_close($this->mbox);
  14. $this->mbox = null;
  15. }
  16. public function fetchFailedOverview() {
  17. $MC = imap_check($this->mbox);
  18. $result = imap_fetch_overview($this->mbox, "1:{$MC->Nmsgs}", 0);
  19. if (is_array($result)) {
  20. foreach ($result as $overview) {
  21. if ($this->filterSubject($overview->subject, 'Delivery Status Notification')) {
  22. $this->email_list[] = $overview->msgno;
  23. }
  24. }
  25. }
  26. return $this->email_list;
  27. }
  28. //$range = "1,2,3,4"
  29. public function moveMessageTo($range, $to='') {
  30. return imap_mail_move($this->mbox, $range , $to);
  31. }
  32. public function listMailBoxes() {
  33. $mailboxes = imap_list($this->mbox, $this->config['settings']['imap']['connection'], '*');
  34. return $mailboxes;
  35. }
  36. public function readEmail($number) {
  37. return imap_qprint(imap_body($this->mbox, $number));
  38. }
  39. public function getSurveyUUID($mail_body='', $check_string='', $length=36) {
  40. $start = strpos($mail_body, $check_string)+strlen($check_string);
  41. return substr($mail_body, $start, $length);
  42. }
  43. private function emptyEmailList() {
  44. $this->email_list = [];
  45. }
  46. public function markDelete($number) {
  47. imap_delete($this->mbox, $number);
  48. }
  49. public function expungeDelete() {
  50. imap_expunge($this->mbox);
  51. }
  52. private function filterSubject($subject='', $filter='') {
  53. if (strpos($subject, $filter) !== false)
  54. return true;
  55. else
  56. return false;
  57. }
  58. }