2011-08-17 37 views
0

我试图添加这个电子邮件插件到我的CakePHP v1.3.3安装,但我有新手问题。cakePHP电子邮件插件 - 配置它到我的CakePHP安装

这里的插件:GitHub SourceCode

我试图按照相当明确的例子,但我不知道要放什么东西了一些对数据源的连接参数。

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

public $emailCardOrder = array(
    'datasource' => 'Emails.Imap', 
    'server' => 'imap.gmail.com', 
    'connect' => 'imap/tls/novalidate-cert', 
    'username' => '[email protected]', 
    '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

任何帮助表示赞赏。

回答

1

小心你的文件imap_source.php确实在正确的路径:app/plugins/emails/! 可能是这些文件在子目录时,您在功能connect WinZip的;-)

所以,第二,我必须改变代码来获得finaly与文件夹的名称在邮箱这样的连接字符串uzip它:
{<server_name_or_ip>:<port><connect_string>}<folder_name>

例如: {server.name.cz:143/imap/notls}INBOX

可能这是爱思华宝一样或MS Exchange服务器的窗户IMAP服务器特产。

您可以控制线504连接的文件imap_source.php成功

-
Mareg

2

您需要将您的数据源改变无论你的数据源名称是。默认情况下,它不是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' => '[email protected]', 
    'password' => '#######', 
    'port' => '993', 
    'ssl' => true, 
    'encoding' => 'UTF-8', 
    'error_handler' => 'php', 
    'auto_mark_as' => array(
     'Seen' //, 
     // 'Answered', 
     // 'Flagged', 
     // 'Deleted', 
     // 'Draft', 
    ), 

);

两年,比从未更晚!

0

这是我设立这个插件

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

数据库。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; 
} 

希望这适用于你