-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac6cdf2
commit f5ece72
Showing
4 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
use PhpMimeMailParser\Attachment; | ||
use PhpMimeMailParser\Parser; | ||
|
||
|
||
class MailService { | ||
|
||
|
||
|
@@ -63,6 +64,15 @@ function __construct(ConfigService $configService, MiscService $miscService) { | |
|
||
|
||
/** | ||
* parse the mail content. | ||
* | ||
* will create a local text file containing the headers and the content of the mail for each one of | ||
* the 'to' or 'cc' mail address correspond to a mail added using the | ||
* "./occ files_frommail:address --add" | ||
* | ||
* Attachments will also be saved on the cloud in the path: | ||
* "Mails sent to [email protected]/From [email protected]/" | ||
* | ||
* @param string $content | ||
* @param string $userId | ||
*/ | ||
|
@@ -74,18 +84,20 @@ public function parseMail($content, $userId) { | |
$data['date'] = date('Y-m-d H:i:s'); | ||
$data['userId'] = $userId; | ||
|
||
$toAddresses = array_merge( | ||
$mail->getAddresses('to'), | ||
$mail->getAddresses('cc'), | ||
$mail->getAddresses('bcc') | ||
); | ||
|
||
$done = []; | ||
$toAddresses = array_merge($mail->getAddresses('to'), $mail->getAddresses('cc')); | ||
foreach ($toAddresses as $toAddress) { | ||
$to = $toAddress['address']; | ||
if (in_array($to, $done)) { | ||
continue; | ||
} | ||
|
||
try { | ||
$this->generateLocalContentFromMail($mail, $toAddress['address'], $data); | ||
$this->generateLocalContentFromMail($mail, $to, $data); | ||
} catch (Exception $e) { | ||
// we check next address | ||
} | ||
|
||
$done[] = $to; | ||
} | ||
} | ||
|
||
|
@@ -106,6 +118,7 @@ private function generateLocalContentFromMail(Parser $mail, $to, $data) { | |
|
||
$this->verifyInfoAndPassword($text, $toInfo); | ||
|
||
$this->count = 0; | ||
$folder = $this->getMailFolder($userId, $to, $from); | ||
$this->createLocalFile($folder, $date, 'mail-' . $subject . '.txt', $text); | ||
$this->createLocalFileFromAttachments($date, $folder, $mail->getAttachments()); | ||
|