NYCPHP Meetup

NYPHP.org

[nycphp-talk] Text file to MySQL entries

Alberto dos Santos yournway at gmail.com
Fri Mar 10 18:07:27 EST 2006


Chris,
Any thoughts on which pattern to use on that explode, or just newlines?

On 10/03/06, csnyder <chsnyder at gmail.com> wrote:
>
> On 3/10/06, Alberto dos Santos <yournway at gmail.com> wrote:
> > Hi all.
> >
> >  Sorry for not knowing my file handling routines 101, but I'm somewhat
> > desperate at this stage, so here it goes.
> >
> >  I have a mail server that sends 200 000 emails daily, no mistake 200K
> with
> > qmail-send, to a mailing list.
> >  Sometimes older users just add another email address and fail to erase
> the
> > old one so I need to comb through the mailbox regularly to find which
> > addresses  are bouncing so I can delete them.
> >  all messages have more or less the same configuration, and we have a
> shell
> > app that compiles the name of the email file and the header onto a text
> > file, something like this:
> >
> >   ./1141578003.21775.ns31756.ovh.net,S=41699
> >  Return-Path: <>
> >  Delivered-To: root at myserver
> >  Received: (qmail 20952 invoked for bounce); 5 Mar 2006 16:59:17 -0000
> >  Date: 5 Mar 2006 16:59:17 -0000
> >  From: MAILER-DAEMON at myserver
> >  To: root at myserver
> >  Subject: failure notice
> >
> >  Hi. This is the qmail-send program at myserver.
> >  I'm afraid I wasn't able to deliver your message to the following
> > addresses.
> >  This is a permanent error; I've given up. Sorry it didn't work out.
> >
> >  <the recipient>:
> >  IPADDRESS does not like recipient.
> >  Remote host said: 550 <the recipient> is not a valid mailbox
> >  Giving up on IPADDRESS
> >
> >  --- Below this line is a copy of the message.
> >
> >
> >
> >  Now, I need to extract the file name, the date, the recipient and the
> error
> > onto a database to check which addresses have bounced and why.
> >
> >  Anybody has some ideas on how I can do that?
> >  I looked on the net and the php manual and found some disparate
> tentatives
> > but no solid solution when we are not using an xml file.
> >
> >  TIA
> > --
> > Alberto dos Santos
> > Consultor em TI
> > IT Consultant
> >
>
> If your script handles these as individual emails, then you could use
> PEAR's MIME parser or one of the imap functions to parse the headers.
>
> Otherwise, well, each message can be converted to an array of lines
> using explode(). Each line of the headers starts with a label. Then
> there's a blank line, and then the message body itself.
>
> Liberal use of strpos(), substr(), etc. should be all you need. Maybe
> some preg_match() if the regular string functions aren't quite enough.
>
>
>
> --
> Chris Snyder
> http://chxo.com/
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> New York PHP Conference and Expo 2006
> http://www.nyphpcon.com
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



--
Alberto dos Santos
Consultor em TI
IT Consultant

http://www.yournway.com
A internet à sua maneira.
The Internet your own way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060310/f8c1a0dc/attachment.html>


More information about the talk mailing list