使用CakePHP IMAP自定义数据源检查电子邮件

时间:2016-01-29 07:59:52

标签: cakephp imap

我想在我的服务器上使用CakePHP IMAP Custom Datasource。

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身份验证有什么问题?

1 个答案:

答案 0 :(得分:0)

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($电子邮件);

    $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($概观);