PHP code example of taitava / swiftmailer-imapsentfolder

1. Go to this page and download the library: Download taitava/swiftmailer-imapsentfolder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

taitava / swiftmailer-imapsentfolder example snippets


use \Taitava\ImapSentFolder\ImapSentFolderPlugin;
$mailer = Swift_Mailer::newInstance();

// Define mailboxes like this:
$mailboxes = [
     '[email protected]' => [
             'host' => 'imap.somedomain.tld',
             'port' => 993,
             'username' => 'email.address',
             'password' => 'verysecretdonotsharepubliclyintheinternet',
        'sent_folder' => 'Sent',
     ],
     'default' => [
             'host' => 'imap.somedomain.tld',
             'port' => 993,
             'username' => 'other.account',
             'password' => 'verysecretdonotsharepubliclyintheinternet',
        'sent_folder' => 'Sent',
     ],
];

$plugin = new ImapSentFolderPlugin($mailboxes);

$mailer->registerPlugin($plugin);

use \Taitava\ImapSentFolder\ImapSentFolderPlugin;
$plugin = new ImapSentFolderPlugin($mailboxes);

$plugin->setCallBeforeSaving(function (Swift_Mime_Message $email_message){
        // ... Inspect the $email_message instance ...

        // ... Decide not to save this message ...
        return false;

        // ... Decide to accept saving the message ...
        return true;

        // ... If you do not write a 'return' statement or if you return null, saving is also accepted ...
        return;
});