PHP๋ IMAP ์๋ฒ๊ฐ ๊ธฐ์กด ์๊ฒฉ ์ฆ๋ช (๋ก๊ทธ์ธ/์ํธ)์ผ๋ก ํด๋ฐฑํ๋๋ผ๋ Kerberos ํฐ์ผ์ด ํ์ํ ๋ ์๋ฆผ์ ํ์ํฉ๋๋ค.
PHP Notice: Unknown: Kerberos error: No credentials cache found (try running kinit) for imap.example.com (errflg=1) in Unknown on line 0
๋ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์๋ฒ ์ฐ๊ฒฐ์ ์ํํ ๋ GSSAPI ์ธ์ฆ์ ๋นํ์ฑํํ ์ ์์ต๋๋ค.
$imapStream = @imap_open($this->imapPath, $this->login, $this->password, 0, 0, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
@tchemineau ๊ฐ์ฌํฉ๋๋ค, 7๋ ํ, ๋น์ ์ ์ผ๋ง๋ ๋ ๋ง์ ์๊ฐ์ ๋ชฐ๋ผ์ ๋ด ์๋ฉ์ด๋ฅผ ๊ตฌํด
setConnectionArgs($options = 0, $retriesNum = 0, $params = null)
ํจ์๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฌํ ๋งค๊ฐ๋ณ์๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use PhpImap\Mailbox;
use PhpImap\Exceptions\ConnectionException;
use PhpImap\Exceptions\InvalidParameterException;
$mailbox = new Mailbox(
'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
'[email protected]', // Username for the before configured mailbox
'*********', // Password for the before configured username
__DIR__, // Directory, where attachments will be saved (optional)
'US-ASCII' // Server encoding (optional)
);
try {
$mailbox->setConnectionArgs(0, 0, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
} catch(InvalidParameterException $ex) {
die("Failed to set connection arguments: " . $ex->getMessage());
}
try {
$mail_ids = $mailbox->searchMailbox('UNSEEN');
} catch(ConnectionException $ex) {
die("IMAP connection failed: " . $ex->getMessage());
} catch (Exception $ex) {
die("An error occured: " . $ex->getMessage());
}
foreach ($mail_ids as $mail_id) { ... }
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์๋ฒ ์ฐ๊ฒฐ์ ์ํํ ๋ GSSAPI ์ธ์ฆ์ ๋นํ์ฑํํ ์ ์์ต๋๋ค.