CakePHP 电子邮件插件 - 使用自定义服务器
我正在尝试制作一种电子邮件客户端。 我找到了以下 CakePHP 数据源类: https://github.com/kvz/cakephp-emails-plugin
看起来非常好,但是我有一个关于服务器详细信息的问题。在插件的自述文件中,它说您应该将 IMAP 服务器作为条目添加到您的 database.php 配置文件中。
我的问题是,由于我的网站允许用户选择自己的 IMAP 服务器,因此我无法将特定服务器硬编码到配置文件中。
我将如何重新设计代码(或者也许您可以从控制器更改数据库设置)以适应我的目的?
I am trying to make a sort of email client.
I found the following 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与我第一次编写它时不太一样,但您可以动态添加数据库配置,请参阅 https://github.com/infinitas/infinitas/blob/beta/app_model.php#L371
您可能还想查看原始代码,因为它正是您想要做的, https://github.com/infinitas/infinitas/tree/beta/core/emails
这是获取特定用户帐户的电子邮件的实际代码 https://github.com/infinitas/infinitas/blob/beta/core/emails/controllers/mail_systems_controller.php#L25
它还包含用户添加帐户详细信息的所有代码ETC。
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.
因为它是一个数据源,所以我相信您可以简单地动态设置 imap 服务器。
Because it's a datasource, I believe you could simply set the imap server on the fly.