php-imap
php-imap copied to clipboard
Save message to file
Is your feature request related to a problem? Please describe. I would like to save a message / email as file. This file should contain both the raw header and raw body (including all attachments).
Describe the solution you'd like
Callable via Message::save($path)
Additional context Inspired by @bilogic question https://github.com/Webklex/laravel-imap/issues/437
This is some simple code I am using to save the email to a .eml file
$eml = "";
$eml .= json_decode(json_encode($email->getHeader()), true)['raw'];
$eml .= $email->getRawBody();
file_put_contents($folder . "/" . $filename, $eml);