473,469 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access to a POP3 mailbox

I am in preliminary design of a contact management program. The
user would like to use his current mail server (POP3 - remote).

I have done some reading on the IMAP functions but am unclear if
the following is possible:

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 ?

all without disturbing the other messages in his inbox that are
downloaded to his usual email client (Thunderbird).

If anyone can suggest a better way to do this, I am all ears.

bill
Mar 22 '07 #1
4 4158
C.
On 22 Mar, 11:18, bill <nob...@spamcop.netwrote:
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);
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.

Mar 22 '07 #2
Hello,

on 03/22/2007 08:18 AM bill said the following:
I am in preliminary design of a contact management program. The user
would like to use his current mail server (POP3 - remote).

I have done some reading on the IMAP functions but am unclear if the
following is possible:

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 ?

all without disturbing the other messages in his inbox that are
downloaded to his usual email client (Thunderbird).

If anyone can suggest a better way to do this, I am all ears.
You may want to take a look at this POP3 class. You can use the class
RetrieveMessage function to retrieve just the message headers and get
only the first body lines you need.

http://www.phpclasses.org/pop3class

You can also this MIME message parser class that can decode message and
extract headers that use non-ASCII characters. I think you need that to
filter message by subject or sender, as messages with non-ASCII
characters are encoded with q-encoding like this:

=?iso-8859-1?Q?

http://www.phpclasses.org/mimeparser

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Mar 22 '07 #3
C. wrote:
On 22 Mar, 11:18, bill <nob...@spamcop.netwrote:
>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
Mar 23 '07 #4
Manuel Lemos wrote:
Hello,

on 03/22/2007 08:18 AM bill said the following:
>I am in preliminary design of a contact management program. The user
would like to use his current mail server (POP3 - remote).

I have done some reading on the IMAP functions but am unclear if the
following is possible:

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 ?

all without disturbing the other messages in his inbox that are
downloaded to his usual email client (Thunderbird).

If anyone can suggest a better way to do this, I am all ears.

You may want to take a look at this POP3 class. You can use the class
RetrieveMessage function to retrieve just the message headers and get
only the first body lines you need.

http://www.phpclasses.org/pop3class

You can also this MIME message parser class that can decode message and
extract headers that use non-ASCII characters. I think you need that to
filter message by subject or sender, as messages with non-ASCII
characters are encoded with q-encoding like this:

=?iso-8859-1?Q?

http://www.phpclasses.org/mimeparser
Thank you
Mar 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Franksmann | last post by:
Hello, I'm going to write a anti-spam-program based on a Whitelist. "If the mail sender is found in the database, my program should move the mail into another mailbox" The mailserver fetched the...
4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
1
by: Lev Altshuler | last post by:
Hi, I am trying to count email messages in the mailbox and read their headers. In case that there are some messages on the POP3 server and they haven't yet got to the Inbox, I get a number of...
7
by: gj | last post by:
I have an application in Access 97 I will be rewriting in the latest version of Access in 6 months. In the meantime, does anyone know of an ActiveX control I can add into an Access 97 form to...
2
by: Mike Brearley | last post by:
I need to write a script that will check a catch-all mailbox (pop3) and send a non delivery report back to the sender of the email. Background info: I have a domain hosted on a site that offers...
0
by: Gabe Matteson | last post by:
Good morning, The point of this posting is to find out a way to insert downloaded email into your exchange mailbox. 1. I know how to download pop3 mail using asp to a web page. 2. i would like to...
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
5
by: Craig Buchanan | last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want to ensure that each message is processed by only one client. In essence, I would like to treat a POP3 mailbox like a...
0
by: wassimdaccache | last post by:
Dear I installed a pop3 service on windows server 2003 Enterprise X64. I am using it to send email internally. I am adding mailbox using pop3 service administrative in the control panel. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.