shahariaazam/cakephp-datasource-imap 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shahariaazam/cakephp-datasource-imap

最新稳定版本:2.0

Composer 安装命令:

composer require shahariaazam/cakephp-datasource-imap

包简介

Imap datasource plugin for CakePHP

README 文档

README

Custom datasource for CakePHP (2.x) to interact with your mail server with IMAP functionality.

Put the ImapSource.php datasource in your app/Model/Datasource directory and just setup like the following.

<?php //app/Model/CustomEmail.php class CustomEmail extends AppModel { // Important: public $useDbConfig = 'myCustomEmail'; public $useTable = false; // Whatever: public $displayField = 'subject'; public $limit = 10; // Semi-important: // You want to use the datasource schema, and still be able to set // $useTable to false. So we override Cake's schema with that exception: function schema($field = false) { if (!is_array($this->_schema) || $field === true) { $db =& ConnectionManager::getDataSource($this->useDbConfig); $db->cacheSources = ($this->cacheSources && $db->cacheSources); $this->_schema = $db->describe($this, $field); } if (is_string($field)) { if (isset($this->_schema[$field])) { return $this->_schema[$field]; } else { return null; } } return $this->_schema; } }

Now you need to define credentials in your app/Config/Database.php with the following code.

<?php //app/Config/Database.php public $myCustomEmail = array( 'datasource' => 'ImapSource', 'server' => 'YourIMAPServerHost', 'username' => 'IMAPServerUsername', 'password' => 'yourIMAPPassword', 'port' => 'IMAPServerPort', 'ssl' => true, 'encoding' => 'UTF-8', 'error_handler' => 'php', 'auto_mark_as' => array( 'Seen', // 'Answered', // 'Flagged', // 'Deleted', // 'Draft', ), );

Now from your controller just access your email like below:

<?php // app/Controller/MailsController.php //your controller codes ... public function index() { $this->loadModel('CustomEmail'); $emails = $this->CustomEmail->find('first'); var_dump($emails); die(); }

Now you will get the email. See the debug output. If you have any question please feel free to mail me at shaharia.azam@gmail.com

统计信息

  • 总下载量: 15.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固