我想给我的收件箱中的一些邮件应用标签,我使用以下代码:
$hostname = '{imap.gmail.com:993/imap/ssl}';
$inbox = $hostname.'INBOX';
$mbox = imap_open($inbox, $username, $password)
or die('Cannot connect to Gmail: ' . imap_last_error());
$label_mailbox = $hostname.'test_label';
$copy_success = imap_mail_copy($mbox, '1,2,3', $label_mailbox);
if ($create_success) {
echo 'Label added.';
} else {
die('Cannot create mailbox: '.imap_last_error());
}
/* close the connection */
imap_close($mbox);
但是结果是:
Cannot copy to mailbox : [TRYCREATE] No folder {imap.gmail.com:993/imap/ssl}test_label (Failure)
谁能告诉我为什么它不起作用?我确定这个标签是存在的
解决方案是只使用标签名而不使用主机名。例如not
{imap.gmail.com:993/imap/ssl}test_label
,
test_label