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

check email with CakePHP IMAP Custom Datasource

我想在带有 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 设置为 143 或将 ssl 设置为 true 时,出现此错误:-

Error: Unable to get imap_thread after 4 retries. 'TLS/SSL failure for radindesign.com: SSL negotiation failed'

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

Unable to get imap_thread after 4 retries. 'Certificate failure for test.com: self signed certificate: /CN=linux10.centraldnserver.com/emailAddress=ssl@linux10.centraldnserver.com'

IMAP 身份验证有什么问题?

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