【问题标题】:cakePHP email plugin - problems configuring it to my CakePHP installationcakePHP 电子邮件插件 - 将其配置到我的 CakePHP 安装时出现问题
【发布时间】:2011-10-28 16:54:54
【问题描述】:

我正在尝试将此电子邮件插件添加到我的 CakePHP v1.3.3 安装中,但是遇到了新手问题。

这是插件:GitHub SourceCode

我尝试遵循相当清晰的示例,但我不确定为数据源连接的某些参数设置什么。

我有一个要通过 IMAP 连接的 Gmail 帐户。这是我的数据库代码。我不确定要为“连接”和“数据源”添加什么。

public $emailCardOrder = array(
    'datasource' => 'Emails.Imap',
    'server' => 'imap.gmail.com',
    'connect' => 'imap/tls/novalidate-cert',
    'username' => 'abcd@gmail.com',
    'password' => '#######',
    'port' => '993',
    'ssl' => true,
    'encoding' => 'UTF-8',
    'error_handler' => 'php',
    'auto_mark_as' => array(
        'Seen',
        // 'Answered',
        // 'Flagged',
        // 'Deleted',
        // 'Draft',
    ),
);

我得到的错误是: PHP Fatal error: ConnectionManager::loadDataSource - Unable to import DataSource class Emails.ImapSource in /repos/intranet/trunk/cake/libs/model/connection_manager.php on line 185

感谢任何帮助。

【问题讨论】:

    标签: plugins cakephp-1.3 email gmail-imap


    【解决方案1】:

    您需要将数据源更改为您的数据源名称。默认情况下,它不是 Emails.Imap。该插件名为 CakePHP-Email-Plugin,所以它应该是 'CakePHP-Email-Plugin.ImapSource'。

    public $emailCardOrder = array(
        'datasource' => 'CakePHP-Email-Plugin.ImapSource',
        'server' => 'imap.gmail.com',
        'connect' => 'imap/tls/novalidate-cert',
        'username' => 'abcd@gmail.com',
        'password' => '#######',
        'port' => '993',
        'ssl' => true,
        'encoding' => 'UTF-8',
        'error_handler' => 'php',
        'auto_mark_as' => array(
            'Seen' //,
            // 'Answered',
            // 'Flagged',
            // 'Deleted',
            // 'Draft',
        ),
    

    );

    两年,迟到总比没有好!

    【讨论】:

      【解决方案2】:

      小心你的文件 imap_source.php 真的在正确的路径:app/plugins/emails/ ! 当您使用 WinZip 解压缩时,这些文件可能在子目录中;-)

      所以,其次,我必须更改函数 connect 中的代码,以最终获得与电子邮件框中文件夹名称连接的字符串,如下所示:
      {<server_name_or_ip>:<port><connect_string>}<folder_name>

      例如: {server.name.cz:143/imap/notls}收件箱

      这可能是爱思华宝或 MS Exchange 服务器等 windows imap 服务器的特色。

      可以在imap_source.php文件的504行控制连接成功

      --
      马雷格

      【讨论】:

        【解决方案3】:

        这是我为这个插件设置的

        我把数据源放在 /app/models/datasource/imap_source.php

        在 database.php 中添加了这个变量

        var $emailTicket = array(
                'datasource' => 'imap',
                'server' => 'imap.gmail.com',
                //'connect' => 'imap/tls/novalidate-cert', //comment it out
                'username' => 'username',
                'password' => '*******',
                'port' => '993',
                'ssl' => true,
                'encoding' => 'UTF-8',
                'error_handler' => 'php',
                'auto_mark_as' => array(
                    'Seen',
                    // 'Answered',
                    // 'Flagged',
                    // 'Deleted',
                    // 'Draft',
                )
            );
        

        在我的模型中

        var $useDbConfig = 'emailTicket';
        

        这工作正常,直到您尝试获取附件

        为了获取附件,我取消了这两行的注释,并为标志 is_attachment 注释了另一行

        protected function _awesomePart($Part, $uid) {
            if (!($Part->format = @$this->encodingTypes[$Part->type])) {
                $Part->format = $this->encodingTypes[0];
            }
        
            if (!($Part->datatype = @$this->dataTypes[$Part->type])) {
                $Part->datatype = $this->dataTypes[0];
            }
        
            $Part->mimeType = strtolower($Part->datatype . '/' . $Part->subtype);
        
            $Part->is_attachment = false;
            $Part->filename      = '';
            $Part->name          = '';
            $Part->uid           = $uid;
        
            if ($Part->ifdparameters) {
                foreach ($Part->dparameters as $Object) {
                    if (strtolower($Object->attribute) === 'filename') {
                        #$Part->is_attachment = true; //uncomment this line
                        $Part->filename      = $Object->value;
                    }
                }
            }
        
            if ($Part->ifparameters) {
                foreach ($Part->parameters as $Object) {
                    if (strtolower($Object->attribute) === 'name') {
                        #$Part->is_attachment = true; //uncomment this line
                        $Part->name          = $Object->value;
                    }
                }
            }
        
            if (false !== strpos($Part->path, '.')) {
                $Part->is_attachment = true; //comment this line
            }
        
            return $Part;
        }
        

        希望这对你有用

        【讨论】:

          猜你喜欢
          • 2014-07-07
          • 2015-08-22
          • 2012-06-03
          • 1970-01-01
          • 2011-01-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多