note 111461 added to function.imap-append
| From: | rixsta at hotmail dot com | Date: | Thu, 21 Feb 2013 21:00:01 +0000 |
| Subject: | note 111461 added to function.imap-append | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193720@lists.php.net to get a copy of this message | ||
Hi,
As we have been struggling with this for some time I wanted to share how we got imap_append working
properly with all MIME parts including attachments. If you are sending email and also wish to
append the sent message to the Sent Items folder, I cannot think of an easier way to do this, as
follows:
1) Use SwiftMailer to send the message via PHP.
$message = Swift_Message::newInstance("Subject goes here");
(then add from, to, body, attachments etc)
$result = $mailer->send($message);
2) When you construct the message in step 1) above save it to a variable as follows:
$msg = $message->toString(); (this creates the full MIME message required for imap_append()!!
After this you can call imap_append like this:
imap_append($imap_conn,$mail_box,$msg."\r\n","\\Seen");
I hope this helps the readers, and prevents saves people from doing what we started doing - hand
crafting the MIME messages :-0
----
Server IP: 69.147.83.199
Probable Submitter: 2.103.46.135
----
Manual Page -- http://php.net/manual/en/function.imap-append.php
Edit -- https://master.php.net/note/edit/111461
Del: integrated -- https://master.php.net/note/delete/111461/integrated
Del: useless -- https://master.php.net/note/delete/111461/useless
Del: bad code -- https://master.php.net/note/delete/111461/bad+code
Del: spam -- https://master.php.net/note/delete/111461/spam
Del: non-english -- https://master.php.net/note/delete/111461/non-english
Del: in docs -- https://master.php.net/note/delete/111461/in+docs
Del: other reasons-- https://master.php.net/note/delete/111461
Reject -- https://master.php.net/note/reject/111461
Search -- https://master.php.net/manage/user-notes.php