1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Spam_Email implements IMP_Spam_Base
24: {
25: 26: 27: 28: 29:
30: protected $_email;
31:
32: 33: 34: 35: 36:
37: protected $_format;
38:
39: 40: 41: 42: 43: 44:
45: public function __construct($email, $format)
46: {
47: $this->_email = $email;
48: $this->_format = $format;
49: }
50:
51: 52:
53: public function report(IMP_Contents $contents, $action)
54: {
55: global $injector, $registry;
56:
57: $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
58:
59: switch ($this->_format) {
60: case 'redirect':
61:
62: try {
63: $imp_compose->redirectMessage($contents->getIndicesOb());
64: $imp_compose->sendRedirectMessage($this->_email, false);
65: return true;
66: } catch (IMP_Compose_Exception $e) {
67: $e->log();
68: }
69: break;
70:
71: case 'digest':
72: default:
73: try {
74: $from_line = $injector->getInstance('IMP_Identity')->getFromLine();
75: } catch (Horde_Exception $e) {
76: $from_line = null;
77: }
78:
79:
80: $mime = new Horde_Mime_Part();
81: $mime->setType('multipart/digest');
82:
83: $rfc822 = new Horde_Mime_Part();
84: $rfc822->setType('message/rfc822');
85: $rfc822->setContents($contents->fullMessageText(array(
86: 'stream' => true
87: )));
88:
89: $mime->addPart($rfc822);
90:
91: $spam_headers = new Horde_Mime_Headers();
92: $spam_headers->addMessageIdHeader();
93: $spam_headers->addHeader('Date', date('r'));
94: $spam_headers->addHeader('To', $this->_email);
95: if (!is_null($from_line)) {
96: $spam_headers->addHeader('From', $from_line);
97: }
98: $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action == IMP_Spam::SPAM ? 'spam' : 'innocent', $registry->getAuth()));
99:
100:
101: try {
102: $recip_list = $imp_compose->recipientList(array(
103: 'to' => $this->_email
104: ));
105: $imp_compose->sendMessage($recip_list['list'], $spam_headers, $mime, 'UTF-8');
106: $rfc822->clearContents();
107: return true;
108: } catch (IMP_Compose_Exception $e) {
109: $e->log();
110: $rfc822->clearContents();
111: }
112: break;
113: }
114:
115: return false;
116: }
117:
118: }
119: