barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.65k stars 459 forks source link

Add support for original filename for attachments #633

Closed Sebbo94BY closed 2 years ago

Sebbo94BY commented 2 years ago

Either directly in the constructor:

// Create PhpImap\Mailbox instance for all further actions
$mailbox = new PhpImap\Mailbox(
    '{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
    'some@gmail.com', // Username for the before configured mailbox
    '*********', // Password for the before configured username
    __DIR__, // Directory, where attachments will be saved (optional)
    'UTF-8', // Server encoding (optional)
    true, // Trim leading/ending whitespaces of IMAP path (optional)
    true // Attachment filename mode (optional; false = random filename; true = original filename)
);

Or any time later in the code:

// set attachment filename mode to "original filename"
$mailbox->setAttachmentFilenameMode(true);

You also can get the current configuration:

// get current attachment filename mode
// true => original filename
// false => random filename (default; old known behaviour by this library)
$mailbox->getAttachmentFilenameMode();

Resolves #589.