Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages: Add ability to native save mail content to file #556

Merged
merged 2 commits into from
Feb 16, 2023

Conversation

jakubboucek
Copy link
Contributor

@jakubboucek jakubboucek commented Feb 13, 2023

PR is adding ability to store raw Message (or their parts) to file directly via native imap_savebody() function.

Direct handling I/O is much more effective than fetch Message Body as string and than save it. Some messages may have huge size, it may waste process memory.

Example how to simple store Message content file:

$filename = 'message-content.eml';
$message->saveRawMessage($filename);

Streams

The imap_savebody() function supports Streams too, this provides the ability to connect elements with pipes for effective manipulating with mail content.

Example how to simple store Message content to compressed file with single atomic operation:

$file = gzopen('message-content.eml.gz', 'wb');
$message->saveRawMessage($file);
gzclose($file);
  • Add tests.

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Base: 94.76% // Head: 94.73% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (ce12e39) compared to base (a238641).
Patch coverage: 92.30% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #556      +/-   ##
============================================
- Coverage     94.76%   94.73%   -0.04%     
- Complexity      356      360       +4     
============================================
  Files            45       45              
  Lines           898      911      +13     
============================================
+ Hits            851      863      +12     
- Misses           47       48       +1     
Impacted Files Coverage Δ
src/Message/AbstractPart.php 95.51% <88.88%> (-0.41%) ⬇️
src/Message.php 85.84% <100.00%> (+0.25%) ⬆️
src/Message/EmbeddedMessage.php 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jakubboucek
Copy link
Contributor Author

Really IDK how to meaningfully test \Ddeboer\Imap\Message\EmbeddedMessage::saveRawMessage().

@Slamdunk
Copy link
Collaborator

Really IDK how to meaningfully test \Ddeboer\Imap\Message\EmbeddedMessage::saveRawMessage().

Just add few meaningful lines to \Ddeboer\Imap\Tests\EmbeddedMessageTest I'd say, and we are ready to merge 💪

@Slamdunk Slamdunk merged commit 92647fd into ddeboer:master Feb 16, 2023
@jakubboucek jakubboucek deleted the feature/jb-message-save-raw branch February 16, 2023 10:31
@jakubboucek
Copy link
Contributor Author

@Slamdunk Thanks to merge 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants