【问题标题】:check email with CakePHP IMAP Custom Datasource使用 CakePHP IMAP 自定义数据源检查电子邮件
【发布时间】:2016-01-29 07:59:51
【问题描述】:

我想在我的服务器上使用我的电子邮件和 CakePHP IMAP 自定义数据源。

database.php 我有:-

public $myCustomEmail = array(
    'datasource' => 'ImapSource',
    'server' => 'test.com',
    'username' => 'info@test.com',
    'password' => 'email password',
    'port' => 143,
    'ssl' => true,
    'encoding' => 'UTF-8',
    'error_handler' => 'php',
    'auto_mark_as' => array(
        'Seen',
        // 'Answered',
        // 'Flagged',
        // 'Deleted',
        // 'Draft',
    ),
);

当我将 port 设置为 143ssl 设置为 true 时,我收到此错误:-

错误:重试 4 次后无法获取 imap_thread。 'radindesign.com 的 TLS/SSL 失败:SSL 协商失败'

ssl 设置为false 或我更改port 时,我收到此错误:-

重试 4 次后无法获取 imap_thread。 'test.com 的证书失败:自签名证书:/CN=linux10.centraldnserver.com/emailAddress=ssl@linux10.centraldnserver.com'

IMAP 身份验证出了什么问题?

【问题讨论】:

  • 我猜你必须将"/novalidate-cert" 添加到连接字符串中(不要在生产中使用!)。数据源不支持,因此您可以将其添加到第 530 行的 ImapSource,php 中,并向存储库发送 pull request

标签: cakephp imap


【解决方案1】:

CakePHP IMAP 自定义数据源并没有帮助我使用这个:

// Configure your imap mailboxes
$mailboxes = array(
array(
    'label'     => 'Gmail',
    'mailbox'   => '{imap.gmail.com:993/imap/ssl}INBOX',
    'username'  => 'yourusername@gmail.com',
    'password'  => 'yourpassword'
),
array(
    'label'     => 'My Cpanel website',
    'mailbox'   => '{mail.yourdomain.com:143/notls}INBOX',
    'username'  => 'info+yourdomain.com',
    'password'  => 'yourpassword'
),
array(
    'label'     => 'Another mail account',
    'mailbox'   => '{mail.yourdomain.com:143/notls}INBOX',
    'username'  => 'info@yourdomain.com',
    'password'  => 'yourpassword'
)

);

       //check inbox
    $current_mailbox = array(
        'label' => 'My Cpanel website',
        'mailbox' => '{mail.test.com:143/notls}INBOX',
        'username' => 'info@test.com',
        'password' => '***'
    );
    // Open an IMAP stream to our mailbox
    $stream = @imap_open($current_mailbox['mailbox'], $current_mailbox['username'], $current_mailbox['password']);

    $emails = imap_search($stream, 'SINCE ' . date('d-M-Y', strtotime("-1 week")));

// 如果我们有一些电子邮件 ID,将它们从新到旧排序并显示它们 rsort($emails);

    $i = 0;
    $overview = array();
    foreach ($emails as $email_id) {

        // Fetch the email's overview and show subject, from and date.
        $overview[$i] = imap_fetch_overview($stream, $email_id, 0);
        $i++;
    }

var_dump($overview);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-26
    • 2011-07-31
    • 2011-12-08
    • 1970-01-01
    • 2012-04-13
    • 2011-04-06
    • 1970-01-01
    • 2016-08-01
    相关资源
    最近更新 更多