I am trying to make a sort of email client. I found the followi开发者_高级运维ng CakePHP datasource class: https://github.com/kvz/cakephp-emails-plugin
It seems very good, however I have one question regarding the server details. In the plugin's readme it says that you should add the IMAP server as a an entry into your database.php config file.
My problem is that, since my website allows users to choose their own IMAP server, I can't hardcode a specfic server into the config file.
How would I redesign the code (or perhaps you can change database settings from the controller) to fit my purposes?
not quite the same as when I first wrote it, but you can add database configs on the fly, see https://github.com/infinitas/infinitas/blob/beta/app_model.php#L371
you also might want to look at the original code as it does exactly what you want to do, https://github.com/infinitas/infinitas/tree/beta/core/emails
here is the actual code getting the emails of a particular users account https://github.com/infinitas/infinitas/blob/beta/core/emails/controllers/mail_systems_controller.php#L25
it also has all the code for users to add their account details etc.
Because it's a datasource, I believe you could simply set the imap server on the fly.
$this->emailTicket['server'] = $servername;
精彩评论