note 105303 added to function.imap-append
| From: | Tigggger at osu1 dot php dot net | Date: | Mon, 08 Aug 2011 16:30:45 +0000 |
| Subject: | note 105303 added to function.imap-append | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182334@lists.php.net to get a copy of this message | ||
I encountered 3 problems when attempting to get my server to copy messages to the sent folder.
1. Wouldn't login until I added /novalidate-cert
2. No code example of getting the date sent
3. Including an attachment
Hope this code helps others
<?
$dmy=date("d-M-Y H:i:s");
$dmy.= " +0100"; // Had to do this bit manually as server and me are in different
timezones
$stream=@imap_open("{mailserver.co.uk/novalidate-cert}INBOX.Sent", "username",
"password");
$boundary = "------=".md5(uniqid(rand()));
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$header .= "\r\n";
$file="../path_to/filename.pdf";
$filename="filename.pdf";
$ouv=fopen ("$file", "rb");$lir=fread ($ouv, filesize
("$file"));fclose
($ouv);
$attachment = chunk_split(base64_encode($lir));
$msg2 .= "--$boundary\r\n";
$msg2 .= "Content-Transfer-Encoding: base64\r\n";
$msg2 .= "Content-Disposition: attachment; filename=\"$filename\"\r\n";
$msg2 .= "\r\n";
$msg2 .= $attachment . "\r\n";
$msg2 .= "\r\n\r\n";
$msg3 .= "--$boundary--\r\n";
imap_append($stream,"{mailserver.co.uk/novalidate-cert}INBOX.Sent","From:
Somebody\r\n"."To: test@somewhere.co.uk\r\n"."Date:
$dmy\r\n"."Subject: This is the
subject\r\n"."$header\r\n"."$msg2\r\n"."$msg3\r\n");
imap_close ($stream);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 87.194.151.162
----
Manual Page -- http://www.php.net/manual/en/function.imap-append.php
Edit -- https://master.php.net/note/edit/105303
Del: integrated -- https://master.php.net/note/delete/105303/integrated
Del: useless -- https://master.php.net/note/delete/105303/useless
Del: bad code -- https://master.php.net/note/delete/105303/bad+code
Del: spam -- https://master.php.net/note/delete/105303/spam
Del: non-english -- https://master.php.net/note/delete/105303/non-english
Del: in docs -- https://master.php.net/note/delete/105303/in+docs
Del: other reasons-- https://master.php.net/note/delete/105303
Reject -- https://master.php.net/note/reject/105303
Search -- https://master.php.net/manage/user-notes.php