note 119768 added to function.imap-append
| From: | nanomoow at gmail dot com | Date: | Sat, 20 Aug 2016 18:38:20 +0000 |
| Subject: | note 119768 added to function.imap-append | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206346@lists.php.net to get a copy of this message | ||
// this works for me, better version :].
<?php
$fn = 'filename.zip';
$IMAPhost = 'imap.hostname.com';
// IMAP port 143, 995 or POP3 port 110, 995
$IMAPport = '143';
$IMAPssl = 'tls';
$IMAP =
'{'.$IMAPhost.':'.$IMAPport.'/imap/'.$IMAPssl.'/novalidate-cert}';
$IMAPuser = 'hello@hostname.com';
$msg ='Message text <h1 style="color: #093"> Hello </h1>';
// imap email and password
$ibox = imap_open($IMAP, $_SESSION['email'], $_SESSION['pass']);
$dmy=date("Y-m-d H:i:s");
// pack file contents
$attachment = chunk_split(base64_encode(file_get_contents('tmp/'.$fn)));
$boundary1 = "###".md5(microtime())."###";
$boundary2 = "###".md5(microtime().rand(99,999))."###";
imap_append($ibox, $IMAP."Send"
, "From: Hello <".$IMAPuser.">\r\n"
. "To: ".$email."\r\n"
. "Date: $dmy\r\n"
. "Subject: ".quoted_printable_encode($sub)."\r\n"
. "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/mixed; boundary=\"$boundary1\"\r\n"
. "\r\n\r\n"
. "--$boundary1\r\n"
. "Content-Type: multipart/alternative; boundary=\"$boundary2\"\r\n"
. "\r\n\r\n"
// ADD Plain text data
. "--$boundary2\r\n"
. "Content-Type: text/plain; charset=\"utf-8\"\r\n"
. "Content-Transfer-Encoding: quoted-printable\r\n"
. "\r\n\r\n"
. $msg."\r\n"
. "\r\n\r\n"
// ADD Html content
. "--$boundary2\r\n"
. "Content-Type: text/html; charset=\"utf-8\"\r\n"
. "Content-Transfer-Encoding: quoted-printable \r\n"
. "\r\n\r\n"
. html_entity_decode($msg)."\r\n"
. "\r\n\r\n"
. "--$boundary2\r\n"
. "\r\n\r\n"
// ADD attachment(s)
. "--$boundary1\r\n"
. "Content-Type: image/gif; name=\"$fn\"\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-Disposition: attachment; filename=\"$fn\"\r\n"
. "\r\n\r\n"
. $attachment
. "\r\n\r\n"
. "--$boundary1--\r\n\r\n"
);
// nigdy wiÄcej takich dziwactw :) ble..
?>
----
Server IP: 72.52.91.14
Probable Submitter: 89.230.40.236
----
Manual Page -- http://php.net/manual/en/function.imap-append.php
Edit -- https://master.php.net/note/edit/119768
Del: integrated -- https://master.php.net/note/delete/119768/integrated
Del: useless -- https://master.php.net/note/delete/119768/useless
Del: bad code -- https://master.php.net/note/delete/119768/bad+code
Del: spam -- https://master.php.net/note/delete/119768/spam
Del: non-english -- https://master.php.net/note/delete/119768/non-english
Del: in docs -- https://master.php.net/note/delete/119768/in+docs
Del: other reasons-- https://master.php.net/note/delete/119768
Reject -- https://master.php.net/note/reject/119768
Search -- https://master.php.net/manage/user-notes.php