|
Posted by bill on 03/23/07 17:02
C. wrote:
> On 22 Mar, 11:18, bill <nob...@spamcop.net> wrote:
>> I am in preliminary design of a contact management program. The
>> user would like to use his current mail server (POP3 - remote).
> <snip>
>> Using the IMAP functions can I write a PHP script to:
>> scan the subject lines of all mail in the mailbox ?
>> pop just certain messages from the inbox ?
>> delete those messages from the inbox ?
>>
>
> Yes. Something like...
>
> $in=imap_open(...);
> $msgs=imap_headers($in); // gets the headers from the currently
> available msgs
> foreach ($msgs as $index=>$header) {
> if (strstr($header, $look_for)) { // may want to explicitly extract
> the subject
> $email=imap_fetchstructure($in, $index);
> if ($email && save($email)) {
> imap_delete($in, $index);
> }
> }
> }
> imap_expunge($in);
> imap_close($in);
THank you.
>
>> all without disturbing the other messages in his inbox that are
>> downloaded to his usual email client (Thunderbird).
>>
>
> ...but you need to make sure that he doesn't delete your meassages
> from the mailbox when he downloads the other stuff.
>
>> If anyone can suggest a better way to do this, I am all ears.
>
> It'd be a lot better to handle the messages synchronously, e.g. with a
> custom procmail script launching the PHP script. But that rather
> depends on having POSIX or similar on the MTA or MUA box.
>
> C.
>
I don't have control over the MTA, which is on a mail server that
is not under the same ownership as the php server.
bill
[Back to original message]
|