Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | // we should consider moving these to the settings table | |
19 | // before the 4.1 release | |
20 | define('EMAIL_ACTIVITY_TYPE_ID', NULL); | |
21 | define('MAIL_BATCH_SIZE', 50); | |
5bc392e6 EM |
22 | |
23 | /** | |
b8c71ffa | 24 | * Class CRM_Utils_Mail_EmailProcessor. |
5bc392e6 | 25 | */ |
6a488035 TO |
26 | class CRM_Utils_Mail_EmailProcessor { |
27 | ||
01467aec EE |
28 | const MIME_MAX_RECURSION = 10; |
29 | ||
6a488035 TO |
30 | /** |
31 | * Process the default mailbox (ie. that is used by civiMail for the bounce) | |
32 | * | |
3ff238ae | 33 | * @param bool $is_create_activities |
34 | * Should activities be created | |
6a488035 | 35 | */ |
3ff238ae | 36 | public static function processBounces($is_create_activities) { |
ae5ffbb7 | 37 | $dao = new CRM_Core_DAO_MailSettings(); |
353ffa53 | 38 | $dao->domain_id = CRM_Core_Config::domainID(); |
6a488035 TO |
39 | $dao->is_default = TRUE; |
40 | $dao->find(); | |
41 | ||
42 | while ($dao->fetch()) { | |
3ff238ae | 43 | self::_process(TRUE, $dao, $is_create_activities); |
6a488035 | 44 | } |
6a488035 TO |
45 | } |
46 | ||
47 | /** | |
b8c71ffa | 48 | * Delete old files from a given directory (recursively). |
6a488035 | 49 | * |
77855840 TO |
50 | * @param string $dir |
51 | * Directory to cleanup. | |
52 | * @param int $age | |
53 | * Files older than this many seconds will be deleted (default: 60 days). | |
6a488035 | 54 | */ |
00be9182 | 55 | public static function cleanupDir($dir, $age = 5184000) { |
6a488035 TO |
56 | // return early if we can’t read/write the dir |
57 | if (!is_writable($dir) or !is_readable($dir) or !is_dir($dir)) { | |
58 | return; | |
59 | } | |
60 | ||
61 | foreach (scandir($dir) as $file) { | |
62 | ||
63 | // don’t go up the directory stack and skip new files/dirs | |
64 | if ($file == '.' or $file == '..') { | |
65 | continue; | |
66 | } | |
67 | if (filemtime("$dir/$file") > time() - $age) { | |
68 | continue; | |
69 | } | |
70 | ||
71 | // it’s an old file/dir, so delete/recurse | |
72 | is_dir("$dir/$file") ? self::cleanupDir("$dir/$file", $age) : unlink("$dir/$file"); | |
73 | } | |
74 | } | |
75 | ||
76 | /** | |
b8c71ffa | 77 | * Process the mailboxes that aren't default (ie. that aren't used by civiMail for the bounce). |
ee3db087 SL |
78 | * |
79 | * @return bool | |
80 | * | |
81 | * @throws CRM_Core_Exception. | |
6a488035 | 82 | */ |
00be9182 | 83 | public static function processActivities() { |
ae5ffbb7 | 84 | $dao = new CRM_Core_DAO_MailSettings(); |
353ffa53 | 85 | $dao->domain_id = CRM_Core_Config::domainID(); |
6a488035 TO |
86 | $dao->is_default = FALSE; |
87 | $dao->find(); | |
88 | $found = FALSE; | |
89 | while ($dao->fetch()) { | |
90 | $found = TRUE; | |
2c2409c3 | 91 | self::_process(FALSE, $dao, TRUE); |
6a488035 TO |
92 | } |
93 | if (!$found) { | |
ee3db087 | 94 | throw new CRM_Core_Exception(ts('No mailboxes have been configured for Email to Activity Processing')); |
6a488035 TO |
95 | } |
96 | return $found; | |
97 | } | |
98 | ||
99 | /** | |
fe482240 | 100 | * Process the mailbox for all the settings from civicrm_mail_settings. |
6a488035 | 101 | * |
fd31fa4c | 102 | * @param bool|string $civiMail if true, processing is done in CiviMail context, or Activities otherwise. |
6a488035 | 103 | */ |
00be9182 | 104 | public static function process($civiMail = TRUE) { |
ae5ffbb7 | 105 | $dao = new CRM_Core_DAO_MailSettings(); |
6a488035 TO |
106 | $dao->domain_id = CRM_Core_Config::domainID(); |
107 | $dao->find(); | |
108 | ||
109 | while ($dao->fetch()) { | |
110 | self::_process($civiMail, $dao); | |
111 | } | |
112 | } | |
113 | ||
5bc392e6 EM |
114 | /** |
115 | * @param $civiMail | |
040073c9 | 116 | * @param CRM_Core_DAO_MailSettings $dao |
3ff238ae | 117 | * @param bool $is_create_activities |
118 | * Create activities. | |
5bc392e6 EM |
119 | * |
120 | * @throws Exception | |
ee3db087 | 121 | * @throws CRM_Core_Exception |
5bc392e6 | 122 | */ |
3ff238ae | 123 | public static function _process($civiMail, $dao, $is_create_activities) { |
6a488035 TO |
124 | // 0 = activities; 1 = bounce; |
125 | $usedfor = $dao->is_default; | |
126 | ||
ae5ffbb7 | 127 | $emailActivityTypeId |
d15a97f4 | 128 | = (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) |
129 | ? EMAIL_ACTIVITY_TYPE_ID | |
70a32eb8 | 130 | : CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Inbound Email'); |
6a488035 TO |
131 | |
132 | if (!$emailActivityTypeId) { | |
ee3db087 | 133 | throw new CRM_Core_Exception(ts('Could not find a valid Activity Type ID for Inbound Email')); |
6a488035 TO |
134 | } |
135 | ||
353ffa53 | 136 | $config = CRM_Core_Config::singleton(); |
f0fed404 JF |
137 | $verpSeparator = preg_quote($config->verpSeparator); |
138 | $twoDigitStringMin = $verpSeparator . '(\d+)' . $verpSeparator . '(\d+)'; | |
139 | $twoDigitString = $twoDigitStringMin . $verpSeparator; | |
140 | $threeDigitString = $twoDigitString . '(\d+)' . $verpSeparator; | |
6a488035 TO |
141 | |
142 | // FIXME: legacy regexen to handle CiviCRM 2.1 address patterns, with domain id and possible VERP part | |
143 | $commonRegex = '/^' . preg_quote($dao->localpart) . '(b|bounce|c|confirm|o|optOut|r|reply|re|e|resubscribe|u|unsubscribe)' . $threeDigitString . '([0-9a-f]{16})(-.*)?@' . preg_quote($dao->domain) . '$/'; | |
144 | $subscrRegex = '/^' . preg_quote($dao->localpart) . '(s|subscribe)' . $twoDigitStringMin . '@' . preg_quote($dao->domain) . '$/'; | |
145 | ||
146 | // a common-for-all-actions regex to handle CiviCRM 2.2 address patterns | |
147 | $regex = '/^' . preg_quote($dao->localpart) . '(b|c|e|o|r|u)' . $twoDigitString . '([0-9a-f]{16})@' . preg_quote($dao->domain) . '$/'; | |
148 | ||
149 | // a tighter regex for finding bounce info in soft bounces’ mail bodies | |
619526f6 | 150 | $rpRegex = '/Return-Path:\s*' . preg_quote($dao->localpart) . '(b)' . $twoDigitString . '([0-9a-f]{16})@' . preg_quote($dao->domain) . '/'; |
6a488035 | 151 | |
1a4d92b6 | 152 | // a regex for finding bound info X-Header |
08523e94 O |
153 | $rpXheaderRegex = '/X-CiviMail-Bounce: ' . preg_quote($dao->localpart) . '(b)' . $twoDigitString . '([0-9a-f]{16})@' . preg_quote($dao->domain) . '/i'; |
154 | // CiviMail in regex and Civimail in header !!! | |
1a4d92b6 | 155 | |
6a488035 TO |
156 | // retrieve the emails |
157 | try { | |
158 | $store = CRM_Mailing_MailStore::getStore($dao->name); | |
159 | } | |
353ffa53 | 160 | catch (Exception$e) { |
86bfa4f6 | 161 | $message = ts('Could not connect to MailStore for ') . $dao->username . '@' . $dao->server . '<p>'; |
6a488035 TO |
162 | $message .= ts('Error message: '); |
163 | $message .= '<pre>' . $e->getMessage() . '</pre><p>'; | |
ee3db087 | 164 | throw new CRM_Core_Exception($message); |
6a488035 TO |
165 | } |
166 | ||
6a488035 TO |
167 | // process fifty at a time, CRM-4002 |
168 | while ($mails = $store->fetchNext(MAIL_BATCH_SIZE)) { | |
169 | foreach ($mails as $key => $mail) { | |
170 | ||
171 | // for every addressee: match address elements if it's to CiviMail | |
be2fb01f | 172 | $matches = []; |
6a488035 TO |
173 | $action = NULL; |
174 | ||
175 | if ($usedfor == 1) { | |
176 | foreach ($mail->to as $address) { | |
177 | if (preg_match($regex, $address->email, $matches)) { | |
178 | list($match, $action, $job, $queue, $hash) = $matches; | |
179 | break; | |
180 | // FIXME: the below elseifs should be dropped when we drop legacy support | |
181 | } | |
182 | elseif (preg_match($commonRegex, $address->email, $matches)) { | |
183 | list($match, $action, $_, $job, $queue, $hash) = $matches; | |
184 | break; | |
185 | } | |
186 | elseif (preg_match($subscrRegex, $address->email, $matches)) { | |
187 | list($match, $action, $_, $job) = $matches; | |
188 | break; | |
189 | } | |
190 | } | |
191 | ||
192 | // CRM-5471: if $matches is empty, it still might be a soft bounce sent | |
193 | // to another address, so scan the body for ‘Return-Path: …bounce-pattern…’ | |
194 | if (!$matches and preg_match($rpRegex, $mail->generateBody(), $matches)) { | |
195 | list($match, $action, $job, $queue, $hash) = $matches; | |
196 | } | |
197 | ||
1a4d92b6 DL |
198 | // if $matches is still empty, look for the X-CiviMail-Bounce header |
199 | // CRM-9855 | |
200 | if (!$matches and preg_match($rpXheaderRegex, $mail->generateBody(), $matches)) { | |
201 | list($match, $action, $job, $queue, $hash) = $matches; | |
202 | } | |
08523e94 O |
203 | // With Mandrilla, the X-CiviMail-Bounce header is produced by generateBody |
204 | // is base64 encoded | |
205 | // Check all parts | |
206 | if (!$matches) { | |
6ac3485f | 207 | $all_parts = $mail->fetchParts(); |
08523e94 O |
208 | foreach ($all_parts as $k_part => $v_part) { |
209 | if ($v_part instanceof ezcMailFile) { | |
210 | $p_file = $v_part->__get('fileName'); | |
6ac3485f | 211 | $c_file = file_get_contents($p_file); |
08523e94 | 212 | if (preg_match($rpXheaderRegex, $c_file, $matches)) { |
08523e94 O |
213 | list($match, $action, $job, $queue, $hash) = $matches; |
214 | } | |
215 | } | |
216 | } | |
217 | } | |
218 | ||
6a488035 TO |
219 | // if all else fails, check Delivered-To for possible pattern |
220 | if (!$matches and preg_match($regex, $mail->getHeader('Delivered-To'), $matches)) { | |
221 | list($match, $action, $job, $queue, $hash) = $matches; | |
222 | } | |
223 | } | |
224 | ||
225 | // preseve backward compatibility | |
3ff238ae | 226 | if ($usedfor == 0 || $is_create_activities) { |
6a488035 | 227 | // if its the activities that needs to be processed .. |
5fdd5f80 | 228 | try { |
83cd2236 | 229 | $mailParams = CRM_Utils_Mail_Incoming::parseMailingObject($mail); |
fad9031a | 230 | } |
83cd2236 DH |
231 | catch (Exception $e) { |
232 | echo $e->getMessage(); | |
233 | $store->markIgnored($key); | |
234 | continue; | |
235 | } | |
6a488035 | 236 | |
69c9ffb3 | 237 | require_once 'CRM/Utils/DeprecatedUtils.php'; |
6a488035 TO |
238 | $params = _civicrm_api3_deprecated_activity_buildmailparams($mailParams, $emailActivityTypeId); |
239 | ||
240 | $params['version'] = 3; | |
040073c9 CW |
241 | if (!empty($dao->activity_status)) { |
242 | $params['status_id'] = $dao->activity_status; | |
243 | } | |
6a488035 TO |
244 | $result = civicrm_api('activity', 'create', $params); |
245 | ||
246 | if ($result['is_error']) { | |
247 | $matches = FALSE; | |
248 | echo "Failed Processing: {$mail->subject}. Reason: {$result['error_message']}\n"; | |
249 | } | |
250 | else { | |
251 | $matches = TRUE; | |
7349cf08 | 252 | CRM_Utils_Hook::emailProcessor('activity', $params, $mail, $result); |
6a488035 TO |
253 | echo "Processed as Activity: {$mail->subject}\n"; |
254 | } | |
6a488035 TO |
255 | } |
256 | ||
257 | // if $matches is empty, this email is not CiviMail-bound | |
258 | if (!$matches) { | |
259 | $store->markIgnored($key); | |
260 | continue; | |
261 | } | |
262 | ||
263 | // get $replyTo from either the Reply-To header or from From | |
264 | // FIXME: make sure it works with Reply-Tos containing non-email stuff | |
265 | $replyTo = $mail->getHeader('Reply-To') ? $mail->getHeader('Reply-To') : $mail->from->email; | |
266 | ||
267 | // handle the action by passing it to the proper API call | |
268 | // FIXME: leave only one-letter cases when dropping legacy support | |
269 | if (!empty($action)) { | |
270 | $result = NULL; | |
271 | ||
272 | switch ($action) { | |
273 | case 'b': | |
274 | case 'bounce': | |
275 | $text = ''; | |
276 | if ($mail->body instanceof ezcMailText) { | |
277 | $text = $mail->body->text; | |
278 | } | |
279 | elseif ($mail->body instanceof ezcMailMultipart) { | |
01467aec | 280 | $text = self::getTextFromMultipart($mail->body); |
6a488035 | 281 | } |
9dcd46ef | 282 | elseif ($mail->body instanceof ezcMailFile) { |
283 | $text = file_get_contents($mail->body->__get('fileName')); | |
284 | } | |
6a488035 TO |
285 | |
286 | if ( | |
9b9a8713 | 287 | empty($text) && |
6a488035 TO |
288 | $mail->subject == "Delivery Status Notification (Failure)" |
289 | ) { | |
290 | // Exchange error - CRM-9361 | |
291 | foreach ($mail->body->getParts() as $part) { | |
292 | if ($part instanceof ezcMailDeliveryStatus) { | |
293 | foreach ($part->recipients as $rec) { | |
294 | if ($rec["Status"] == "5.1.1") { | |
9b9a8713 SL |
295 | if (isset($rec["Description"])) { |
296 | $text = $rec["Description"]; | |
297 | } | |
298 | else { | |
0addad12 | 299 | $text = $rec["Status"] . " Delivery to the following recipients failed"; |
9b9a8713 | 300 | } |
6a488035 TO |
301 | break; |
302 | } | |
303 | } | |
304 | } | |
305 | } | |
306 | } | |
307 | ||
308 | if (empty($text)) { | |
309 | // If bounce processing fails, just take the raw body. Cf. CRM-11046 | |
310 | $text = $mail->generateBody(); | |
311 | ||
312 | // if text is still empty, lets fudge a blank text so the api call below will succeed | |
6ac9d864 DL |
313 | if (empty($text)) { |
314 | $text = ts('We could not extract the mail body from this bounce message.'); | |
315 | } | |
6a488035 TO |
316 | } |
317 | ||
be2fb01f | 318 | $params = [ |
6a488035 TO |
319 | 'job_id' => $job, |
320 | 'event_queue_id' => $queue, | |
321 | 'hash' => $hash, | |
322 | 'body' => $text, | |
323 | 'version' => 3, | |
cdc5c450 | 324 | // Setting is_transactional means it will rollback if |
325 | // it crashes part way through creating the bounce. | |
326 | // If the api were standard & had a create this would be the | |
327 | // default. Adding the standard api & deprecating this one | |
328 | // would probably be the | |
329 | // most consistent way to address this - but this is | |
330 | // a quick hack. | |
331 | 'is_transactional' => 1, | |
be2fb01f | 332 | ]; |
6a488035 TO |
333 | $result = civicrm_api('Mailing', 'event_bounce', $params); |
334 | break; | |
335 | ||
336 | case 'c': | |
337 | case 'confirm': | |
338 | // CRM-7921 | |
be2fb01f | 339 | $params = [ |
6a488035 TO |
340 | 'contact_id' => $job, |
341 | 'subscribe_id' => $queue, | |
342 | 'hash' => $hash, | |
343 | 'version' => 3, | |
be2fb01f | 344 | ]; |
6a488035 TO |
345 | $result = civicrm_api('Mailing', 'event_confirm', $params); |
346 | break; | |
347 | ||
348 | case 'o': | |
349 | case 'optOut': | |
be2fb01f | 350 | $params = [ |
6a488035 TO |
351 | 'job_id' => $job, |
352 | 'event_queue_id' => $queue, | |
353 | 'hash' => $hash, | |
354 | 'version' => 3, | |
be2fb01f | 355 | ]; |
6a488035 TO |
356 | $result = civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params); |
357 | break; | |
358 | ||
359 | case 'r': | |
360 | case 'reply': | |
361 | // instead of text and HTML parts (4th and 6th params) send the whole email as the last param | |
be2fb01f | 362 | $params = [ |
6a488035 TO |
363 | 'job_id' => $job, |
364 | 'event_queue_id' => $queue, | |
365 | 'hash' => $hash, | |
366 | 'bodyTxt' => NULL, | |
367 | 'replyTo' => $replyTo, | |
368 | 'bodyHTML' => NULL, | |
369 | 'fullEmail' => $mail->generate(), | |
370 | 'version' => 3, | |
be2fb01f | 371 | ]; |
6a488035 TO |
372 | $result = civicrm_api('Mailing', 'event_reply', $params); |
373 | break; | |
374 | ||
375 | case 'e': | |
376 | case 're': | |
377 | case 'resubscribe': | |
be2fb01f | 378 | $params = [ |
6a488035 TO |
379 | 'job_id' => $job, |
380 | 'event_queue_id' => $queue, | |
381 | 'hash' => $hash, | |
382 | 'version' => 3, | |
be2fb01f | 383 | ]; |
6a488035 TO |
384 | $result = civicrm_api('MailingGroup', 'event_resubscribe', $params); |
385 | break; | |
386 | ||
387 | case 's': | |
388 | case 'subscribe': | |
be2fb01f | 389 | $params = [ |
6a488035 TO |
390 | 'email' => $mail->from->email, |
391 | 'group_id' => $job, | |
392 | 'version' => 3, | |
be2fb01f | 393 | ]; |
6a488035 TO |
394 | $result = civicrm_api('MailingGroup', 'event_subscribe', $params); |
395 | break; | |
396 | ||
397 | case 'u': | |
398 | case 'unsubscribe': | |
be2fb01f | 399 | $params = [ |
6a488035 TO |
400 | 'job_id' => $job, |
401 | 'event_queue_id' => $queue, | |
402 | 'hash' => $hash, | |
403 | 'version' => 3, | |
be2fb01f | 404 | ]; |
6a488035 TO |
405 | $result = civicrm_api('MailingGroup', 'event_unsubscribe', $params); |
406 | break; | |
407 | } | |
408 | ||
409 | if ($result['is_error']) { | |
410 | echo "Failed Processing: {$mail->subject}, Action: $action, Job ID: $job, Queue ID: $queue, Hash: $hash. Reason: {$result['error_message']}\n"; | |
411 | } | |
412 | else { | |
413 | CRM_Utils_Hook::emailProcessor('mailing', $params, $mail, $result, $action); | |
414 | } | |
415 | } | |
416 | ||
417 | $store->markProcessed($key); | |
418 | } | |
419 | // CRM-7356 – used by IMAP only | |
420 | $store->expunge(); | |
421 | } | |
422 | } | |
96025800 | 423 | |
01467aec EE |
424 | /** |
425 | * @param \ezcMailMultipart $multipart | |
426 | * @param int $recursionLevel | |
427 | * | |
428 | * @return array | |
429 | */ | |
430 | protected static function getTextFromMultipart($multipart, $recursionLevel = 0) { | |
431 | if ($recursionLevel >= self::MIME_MAX_RECURSION) { | |
432 | return NULL; | |
433 | } | |
434 | $recursionLevel += 1; | |
435 | $text = NULL; | |
436 | if ($multipart instanceof ezcMailMultipartReport) { | |
437 | $text = self::getTextFromMulipartReport($multipart, $recursionLevel); | |
438 | } | |
439 | elseif ($multipart instanceof ezcMailMultipartRelated) { | |
440 | $text = self::getTextFromMultipartRelated($multipart, $recursionLevel); | |
441 | } | |
442 | else { | |
443 | foreach ($multipart->getParts() as $part) { | |
444 | if (isset($part->subType) and $part->subType === 'plain') { | |
445 | $text = $part->text; | |
446 | } | |
447 | elseif ($part instanceof ezcMailMultipart) { | |
448 | $text = self::getTextFromMultipart($part, $recursionLevel); | |
449 | } | |
450 | if ($text) { | |
451 | break; | |
452 | } | |
453 | } | |
454 | } | |
455 | return $text; | |
456 | } | |
457 | ||
458 | /** | |
459 | * @param \ezcMailMultipartRelated $related | |
460 | * @param int $recursionLevel | |
461 | * | |
462 | * @return array | |
463 | */ | |
464 | protected static function getTextFromMultipartRelated($related, $recursionLevel) { | |
465 | $text = NULL; | |
466 | foreach ($related->getRelatedParts() as $part) { | |
467 | if (isset($part->subType) and $part->subType === 'plain') { | |
468 | $text = $part->text; | |
469 | } | |
470 | elseif ($part instanceof ezcMailMultipart) { | |
471 | $text = self::getTextFromMultipart($part, $recursionLevel); | |
472 | } | |
473 | if ($text) { | |
474 | break; | |
475 | } | |
476 | } | |
477 | return $text; | |
478 | } | |
479 | ||
480 | /** | |
481 | * @param \ezcMailMultipartReport $multipart | |
482 | * @param $recursionLevel | |
483 | * | |
484 | * @return array | |
485 | */ | |
486 | protected static function getTextFromMulipartReport($multipart, $recursionLevel) { | |
487 | $text = NULL; | |
488 | $part = $multipart->getMachinePart(); | |
489 | if ($part instanceof ezcMailDeliveryStatus) { | |
490 | foreach ($part->recipients as $rec) { | |
491 | if (isset($rec["Diagnostic-Code"])) { | |
492 | $text = $rec["Diagnostic-Code"]; | |
493 | break; | |
494 | } | |
495 | elseif (isset($rec["Description"])) { | |
496 | $text = $rec["Description"]; | |
497 | break; | |
498 | } | |
499 | // no diagnostic info present - try getting the human readable part | |
500 | elseif (isset($rec["Status"])) { | |
501 | $text = $rec["Status"]; | |
502 | $textpart = $multipart->getReadablePart(); | |
503 | if ($textpart !== NULL and isset($textpart->text)) { | |
504 | $text .= " " . $textpart->text; | |
505 | } | |
506 | else { | |
507 | $text .= " Delivery failed but no diagnostic code or description."; | |
508 | } | |
509 | break; | |
510 | } | |
511 | } | |
512 | } | |
513 | elseif ($part !== NULL and isset($part->text)) { | |
514 | $text = $part->text; | |
515 | } | |
516 | elseif (($part = $multipart->getReadablePart()) !== NULL) { | |
517 | if (isset($part->text)) { | |
518 | $text = $part->text; | |
519 | } | |
520 | elseif ($part instanceof ezcMailMultipart) { | |
521 | $text = self::getTextFromMultipart($part, $recursionLevel); | |
522 | } | |
523 | } | |
524 | return $text; | |
525 | } | |
526 | ||
6a488035 | 527 | } |