barbushin/php-imap

[Feature Request] Save email to eml file

Opened this issue · 0 comments

I'm sorry if I didn't find the method ( I searched into issues and src/PhpImap/IncomingMail.php )

I wish to save an email to a .eml file ex: $email->save($emailFilePath)

before using your project I used to do something like this :

function save_eml_file($address, $folder, $mailbox_connection, $email_id, $email_number) {
$email_headers = imap_fetchheader($mailbox_connection, $email_number, FT_PREFETCHTEXT);
$email_body = imap_body($mailbox_connection, $email_number);
$save_path = $folder;

if (!file_exists($save_path)) {
    mkdir($save_path, 0777);
}

file_put_contents("".$save_path."/".$email_id.".eml", $email_headers."\n\n".$email_body);  

}

regards