imap_append

(PHP 3, PHP 4, PHP 5)

imap_append --  Append a string message to a specified mailbox

Description

bool imap_append ( resource imap_stream, string mbox, string message [, string options] )

imap_append() appends a string message to the specified mailbox mbox. If the optional options is specified, writes the options to that mailbox also.

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

When talking to the Cyrus IMAP server, you must use "\r\n" as your end-of-line terminator instead of "\n" or the operation will fail.

Пример 1. imap_append() example

<?php
$stream
= imap_open("{your.imap.host}INBOX.Drafts", "username", "password");

$check = imap_check($stream);
echo
"Msg Count before append: ". $check->Nmsgs . "\n";

imap_append($stream, "{your.imap.host}INBOX.Drafts"
                  
, "From: me@example.com\r\n"
                  
. "To: you@example.com\r\n"
                  
. "Subject: test\r\n"
                  
. "\r\n"
                  
. "this is a test message, please ignore\r\n"
                  
);

$check = imap_check($stream);
echo
"Msg Count after append : ". $check->Nmsgs . "\n";

imap_close($stream);
?>



imap_append
bithive
23-Jun-2003 03:26
The parameter description is misleading.  You can pass a string of flags such as '\Seen' [see imap_setflag_full()] as the last argument.  In the other imap functions, 'options' seems to usually refer to a bitmask, not message flags.
michel dot jansens at ulb dot ac dot be
29-Apr-2003 07:29
I use imap_append() to decode message/rfc822 attachments type(embedded emails):

$attachment = imap_fetchbody($mbox,$mailuid,$atpos,FT_UID);
$attachment = imap_base64($attachment);
$res =  imap_append($mbox,mboxspec("INBOX"),$attachment);
//the embedded email is now a normal mail in my INBOX
bluebiru78 at hotmail dot com
12-Jun-2002 12:24
i used imap_append to copy any composed message into INBOX.Sent folder..

$app = imap_append($stream,"{" . $connectstring . "}INBOX.Sent","$header\r\n" ."$mbody\r\n");

if (!$app) {
 error("Email copying to Sent folder FAILED!");
}
owain at vaughan dot com
01-Aug-2001 06:49
With SIMS IMAP server you also need to use \r\n as a line terminator, otherwise you will be able to add all the header lines correctly, but the body of the message will not be saved.<br>
You can use \n by itself for each header line, but when creating the blank line between the headers and the body you must use \r\n\r\n
jesper at angelo dot dk
14-Sep-1999 09:13
Please observe that imap_append() do not support NNTP posting. Use fsockopen() instead, and do the work yourself.

<imap_alertsimap_base64>
 Last updated: Tue, 15 Nov 2005