函数名: imap_append()
适用版本: PHP 4 >= 4.0.2, PHP 5, PHP 7
用法: imap_append(resource $imap_stream, string $mailbox, string $message, string $options = null, string $internal_date = null): bool
解释:imap_append() 函数用于将邮件消息追加到指定邮箱中。该函数可以将已经存在于邮件消息中的头部信息和正文部分追加到指定邮箱。
参数:
返回值:如果成功追加了邮件消息,则返回 true。如果失败,则返回 false。
示例:
// 连接到 IMAP 服务器
$imap_server = "{imap.example.com:993/imap/ssl}";
$imap_user = "your_email@example.com";
$imap_password = "your_password";
$imap_stream = imap_open($imap_server, $imap_user, $imap_password);
// 创建一个新的邮件消息
$message = "Subject: Test Email\r\n";
$message .= "From: sender@example.com\r\n";
$message .= "To: recipient@example.com\r\n";
$message .= "\r\n";
$message .= "This is a test email.";
// 将邮件消息追加到指定邮箱
$mailbox = "INBOX";
if (imap_append($imap_stream, $mailbox, $message)) {
echo "邮件消息成功追加到邮箱!";
} else {
echo "追加邮件消息失败!";
}
// 关闭 IMAP 连接
imap_close($imap_stream);
注意事项: