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

[Feature Request] Save email to eml file #719

Open
Cowprod opened this issue Nov 22, 2023 · 0 comments
Open

[Feature Request] Save email to eml file #719

Cowprod opened this issue Nov 22, 2023 · 0 comments
Labels
needs investigation This will be tested / debugged or checked out.

Comments

@Cowprod
Copy link

Cowprod commented Nov 22, 2023

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

@Cowprod Cowprod added the needs investigation This will be tested / debugged or checked out. label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

1 participant