I'm considering, rather than specifying authentication parameters etc, such as this:
Code: Select all
$mailbox = new Swift_Mailbox(
new Swift_Mailbox_Drivers_ImapDriver('imap.gmail.com', 993, 'ssl', 'username', 'password')
);
//Or even
$driver = new Swift_Mailbox_Drivers_ImapDriver('imap.gmail.com', 993, 'ssl');
$driver->setUsername('username');
$driver->setPassword('password');
$mailbox = new Swift_Mailbox($driver);Code: Select all
$mailbox = new Swift_Mailbox(
new Swift_Mailbox_Drivers_ImapDriver('imaps://username:password@imap.gmail.com')
);
Perhaps the underlying implementation should use parameters in the constructor, but a factory method allows creation from a DSN:
Code: Select all
$driver = Swift_Mailbox_Drivers_ImapDriver::fromDsn( ... );The advantage of the DSN approach is that a higher level DriverFactory may be provided that uses the DSN to create the underlying Drivers such as IMAP or POP3.
Code: Select all
$driver = Swift_Mailbox_DriverFactory::createDriverFromDsn('imap://user:pass@imap.hostname.tld');
// $driver is an instance of Swift_Mailbox_Drivers_ImapDriver
$driver = Swift_Mailbox_DriverFactory::createDriverFromDsn('pop3://user:pass@imap.hostname.tld');
// $driver is an instance of Swift_Mailbox_Drivers_Pop3Driver