Re: Access to a POP3 mailbox



C. wrote:
On 22 Mar, 11:18, bill <nob...@xxxxxxxxxxx> 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
.



Relevant Pages

  • Re: Mail back-up system
    ... MTA is sendmail/milter. ... Mailbox format might not be a bottleneck in this application. ... I could see this as an advantage of the Maildirs format. ... create a full mail server using vpopmail, courier, maildirs, spam/virus ...
    (freebsd-questions)
  • Re: deleting old mails
    ... I tried mail/archivemail but it cannot create it's lock file ... A few words about locking. ... The answer is simple: no mailbox is ever ... On the mail server the home diretory is NFS-mounted read-only just to ...
    (freebsd-questions)
  • Re: deleting old mails
    ... I tried mail/archivemail but it cannot create it's lock file ... A few words about locking. ... The answer is simple: no mailbox is ever ... On the mail server the home diretory is NFS-mounted read-only just to ...
    (freebsd-questions)
  • Re: An argument AGAINST hosting your own email domain.
    ... I run an industrial-strength mail server with ... >to 'auth attacks', NDR attacks, attacks which have yet to be invented, or ... >In the past we didn't like the 'POP Connector', there was a problem where it ... >from an individual mailbox and assign it to an Exchange mailbox works, ...
    (microsoft.public.windows.server.sbs)
  • Re: Exchange 2003 Storage Group Space Problem !
    ... I already retain day to 0, and how can do offline defrag ... receive mail will autoforward to one mailbox account, so i only backup this ... >> Event log from this mail server, this mail server have release a number ...
    (microsoft.public.exchange2000.admin)