-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from barbushin/develop
Release 3.1.0
- Loading branch information
Showing
25 changed files
with
4,539 additions
and
798 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[composer.json] | ||
indent_style = space |
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
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 |
---|---|---|
|
@@ -19,15 +19,38 @@ | |
"email": "[email protected]" | ||
} | ||
], | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"require": { | ||
"php": ">=5.6", | ||
"ext-fileinfo": "*", | ||
"ext-iconv": "*", | ||
"ext-imap": "*", | ||
"ext-mbstring": "*", | ||
"ext-iconv": "*" | ||
"ext-mbstring": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^5.7", | ||
"squizlabs/php_codesniffer": "^3.4" | ||
"friendsofphp/php-cs-fixer": "^2.16", | ||
"jakub-onderka/php-parallel-lint": "^1.0", | ||
"paragonie/random_compat": "^1", | ||
"phpunit/phpunit": "^5.7" | ||
}, | ||
"scripts": { | ||
"tests": [ | ||
"parallel-lint .php_cs.dist src tests examples", | ||
"phpunit", | ||
"composer-require-checker check ./composer.json", | ||
"psalm --show-info=false", | ||
"php-cs-fixer fix --allow-risky=yes --no-interaction --dry-run --diff-format=udiff -v" | ||
] | ||
}, | ||
"suggest": { | ||
"ext-fileinfo": "To facilitate IncomingMailAttachment::getMimeType() auto-detection" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"PhpImap\\": "tests/unit" | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
|
Empty file.
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 |
---|---|---|
@@ -1,29 +1,28 @@ | ||
<?php | ||
|
||
/** | ||
* Example: Get and parse all emails which match the subject "part of the subject" with saving their attachments. | ||
* | ||
* @author Sebastian Krätzig <[email protected]> | ||
*/ | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
use PhpImap\Mailbox; | ||
/** | ||
* Example: Get and parse all emails which match the subject "part of the subject" with saving their attachments. | ||
* | ||
* @author Sebastian Krätzig <[email protected]> | ||
*/ | ||
require_once __DIR__.'/../vendor/autoload.php'; | ||
use PhpImap\Exceptions\ConnectionException; | ||
use PhpImap\Mailbox; | ||
|
||
$mailbox = new Mailbox( | ||
'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder | ||
'[email protected]', // Username for the before configured mailbox | ||
'*********', // Password for the before configured username | ||
__DIR__, // Directory, where attachments will be saved (optional) | ||
'US-ASCII' // Server encoding (optional) | ||
'US-ASCII' // Server encoding (optional) | ||
); | ||
|
||
try { | ||
$mail_ids = $mailbox->searchMailbox('SUBJECT "part of the subject"'); | ||
} catch(ConnectionException $ex) { | ||
die("IMAP connection failed: " . $ex->getMessage()); | ||
} catch (ConnectionException $ex) { | ||
die('IMAP connection failed: '.$ex->getMessage()); | ||
} catch (Exception $ex) { | ||
die("An error occured: " . $ex->getMessage()); | ||
die('An error occured: '.$ex->getMessage()); | ||
} | ||
|
||
foreach ($mail_ids as $mail_id) { | ||
|
@@ -34,39 +33,39 @@ | |
false // Do NOT mark emails as seen (optional) | ||
); | ||
|
||
echo "from-name: " . (isset($email->fromName)) ? $email->fromName : $email->fromAddress . "\n"; | ||
echo "from-email: " . $email->fromAddress . "\n"; | ||
echo "to: " . $email->to . "\n"; | ||
echo "subject: " . $email->subject . "\n"; | ||
echo "message_id: " . $email->messageId . "\n"; | ||
echo "mail has attachments? "; | ||
echo 'from-name: '.(string) (isset($email->fromName) ? $email->fromName : $email->fromAddress)."\n"; | ||
echo 'from-email: '.(string) $email->fromAddress."\n"; | ||
echo 'to: '.(string) $email->toString."\n"; | ||
echo 'subject: '.(string) $email->subject."\n"; | ||
echo 'message_id: '.(string) $email->messageId."\n"; | ||
|
||
echo 'mail has attachments? '; | ||
if ($email->hasAttachments()) { | ||
echo "Yes\n"; | ||
} else { | ||
echo "No\n"; | ||
} | ||
|
||
if (!empty($email->getAttachments())) { | ||
echo count($email->getAttachments()) . " attachements\n"; | ||
echo \count($email->getAttachments())." attachements\n"; | ||
} | ||
if ($email->textHtml) { | ||
echo "Message HTML:\n" . $email->textHtml; | ||
echo "Message HTML:\n".$email->textHtml; | ||
} else { | ||
echo "Message Plain:\n" . $email->textPlain; | ||
echo "Message Plain:\n".$email->textPlain; | ||
} | ||
|
||
if (!empty($email->autoSubmitted)) { | ||
// Mark email as "read" / "seen" | ||
$mailbox->markMailAsRead($mail_id); | ||
echo "+------ IGNORING: Auto-Reply ------+\n"; | ||
echo "+------ IGNORING: Auto-Reply ------+\n"; | ||
} | ||
|
||
if (!empty($email_content->precedence)) { | ||
// Mark email as "read" / "seen" | ||
$mailbox->markMailAsRead($mail_id); | ||
echo "+------ IGNORING: Non-Delivery Report/Receipt ------+\n"; | ||
} | ||
} | ||
} | ||
|
||
$mailbox->disconnect(); | ||
$mailbox->disconnect(); |
Oops, something went wrong.