10 Years
Discussion Span
Last Post by MattEvans

well... it depends on your mailbox format... on my server, an "inbox" is stored in a single file (every new message is appended to the end of that file). and each of my "official" inboxes has its own file... to make head and/or tail of that, i'd have to read the file, split out each individual message, and parse the headers... if your mailbox is different, the format of stored messages may be different.

if your mailbox is "offshore", i.e. not on the server where you want to perform the check, you'll need to make a POP3 or similar connection to ge hold of the mail.. I know Perl offers handy modules for that purpose, for PHP... the same probably applies.

here's an insightful snippet from my "root" inbox file (/home/fusion/mail/inbox)

From MAILER-DAEMON Fri Dec  1 15:37:46 2006
Date: 01 Dec 2006 15:37:46 +0000
From: Mail System Internal Data <MAILER-DAEMON@{hidden}>
Message-ID: <1164987489@{hidden}>
X-IMAP: 1156397484 0000000411
Status: RO

This text is part of the internal format of your mail folder, and is not
a real message.  It is created automatically by the mail system software.
If deleted, important folder data will be lost, and it will be re-created
with the data reset to initial values.

From {hidden} Mon Dec 04 23:26:52 2006
Return-path: <{hidden}>
Envelope-to: {hidden}
Delivery-date: Mon, 04 Dec 2006 23:26:52 +0000
Received: from [] (helo=gabriel)
	by {hidden} with esmtp (Exim 4.52)
	id 1GrNDN-0000hq-0m
	for {hidden}; Mon, 04 Dec 2006 23:26:52 +0000
Received: from (HELO ismtp.{hidden})
     by {hidden} with esmtp (P27LR+)+6*.> ,.DM.)
     id EG@B)K-7UK.L:-5/
     for{hidden}; Mon, 4 Dec 2006 23:27:30 +0180
Message-ID: <01c717fb$c4a471d0$6c822{hidden}>
From: "Gina Reagan" <{hidden}>
To: <{hidden}>
Subject: We accepted your loan request
Date: Mon, 4 Dec 2006 23:27:30 +0180
MIME-Version: 1.0
Content-Type: multipart/alternative;
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1437

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

Thank you for your loan request, which we recieved yesterday, your refinanc=
e application has been acceptedBad credit OK, We are ready to give you a $3=
13,000 loan, after further review, our lenders have established the lowest =
monthly payments.Approval process will take only 1 minute.Please visit the =
confirmation link below and fill-out our short 30 second Secure Web-Form ww=
{there was a load more here, but the "next part" bits are most important... they separate each message (and each part of a multipart message}

have a poke around your server and look at the mail format...


Thank you for your post. Unfortunately, I'm using qmail, and each message is its own file. I tried checking out the qmail log, but couldn't find a pattern to find the emails (some were wrapped in parentheses, others in brackets, others underscores, etc) so that didn't work :( I'm still trying!


hmm.. it should in theory be easier in a one-file-per-message system: there's one less parse operation to perform, and that's replaced with reading in all the files in a given directory...


reading the qmail-log manual leads me to believe it's very volatile o_O, but it may provide a notification of a bounced message without waiting for a notification email from your mailserver.

if you have a specified email address (or inbox) to forward, at delivery-level, all failed notifcations from your mail server to (they definately have common subject lines), it will make the job of working out what data is important easier.

there is a PHP POP module, someone has written a wrapper for it aswell:


but... if your message folder is local to your script, that does seem like uneccessary overhead.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.