Method to download whole email as .eml
Closed this issue · 1 comments
guruprotect commented
I love this class and I have a particular use case that involves me saving a copy of the email in eml format (headers and body) to the local disk. Is this possible? I cant see a way looking through the code.
benhall14 commented
It's taken a while to get around to this update, and you may have found a different solution in the meantime, but you can now call the saveEml() method on the looped Email to save the .eml file by passing in a file name.
For example:
foreach ($reader->emails() as $email) {
// save the email into a id named .eml file.
$email->saveEml($email->id() . '.eml');
// You can also just retrieve the .eml content by using ->eml()
$eml_content = $email->eml();
}
Thanks,
Ben