get all the email addresses from a text file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nico

    get all the email addresses from a text file

    Hi,

    I have a .txt file with a lot of text mixed with some email addresses. I
    would like to get all the email addresses in a $mails[] variable. Does
    anyone know how to do this in php.

    Thanks a lot for your help,

    Nicholas


  • ZeldorBlat

    #2
    Re: get all the email addresses from a text file


    Nico wrote:[color=blue]
    > Hi,
    >
    > I have a .txt file with a lot of text mixed with some email addresses. I
    > would like to get all the email addresses in a $mails[] variable. Does
    > anyone know how to do this in php.
    >
    > Thanks a lot for your help,
    >
    > Nicholas[/color]

    What does the .txt file look like? (Please don't say HTML)

    Comment

    • Nico

      #3
      Re: get all the email addresses from a text file


      "ZeldorBlat " <zeldorblat@gma il.com> a écrit dans le message de news:
      1143047047.2939 59.114180@g10g2 00...legr oups.com...
      [color=blue]
      > What does the .txt file look like? (Please don't say HTML)[/color]


      Well it looks like that :


      Email : bois.massif@wan adoo.fr
      Errors : 3
      Reason : 550 <bois.massif@wa nadoo.fr>: Recipient address rejected: User
      unknown

      Email : subaruclamp@aol .com
      Errors : 2
      Reason : 550 <subaruclamp@ao l.com>... User unknown

      Email : sylvie.ravise@i nfonie.fr
      Errors : 64
      Reason : 552 RCPT TO:<sylvie.ravi se@infonie.fr> Mailbox disk quota exceeded

      Email : c.sibe@cario.fr
      Errors : 2
      Reason : 550 <c.sibe@cario.f r> ... recipient rejected

      Email : hohiojijoioh@cl ub-internet.fr
      Errors : 8
      Reason : 550 <hohiojijoioh@c lub-internet.fr>: Recipient address rejected:
      User unknown in local recipient table


      Comment

      • Nico

        #4
        Re: get all the email addresses from a text file

        The ultimate goal is to clean up my database of undeliverable mails.

        "Nico" <fab.abc@free.f r> a écrit dans le message de news:
        44218bdb$0$2964 9$636a55ce@news .free.fr...[color=blue]
        >
        > "ZeldorBlat " <zeldorblat@gma il.com> a écrit dans le message de news:
        > 1143047047.2939 59.114180@g10g2 00...legr oups.com...
        >[color=green]
        >> What does the .txt file look like? (Please don't say HTML)[/color]
        >
        >
        > Well it looks like that :
        >
        >
        > Email : bois.massif@wan adoo.fr
        > Errors : 3
        > Reason : 550 <bois.massif@wa nadoo.fr>: Recipient address rejected: User
        > unknown
        >
        > Email : subaruclamp@aol .com
        > Errors : 2
        > Reason : 550 <subaruclamp@ao l.com>... User unknown
        >
        > Email : sylvie.ravise@i nfonie.fr
        > Errors : 64
        > Reason : 552 RCPT TO:<sylvie.ravi se@infonie.fr> Mailbox disk quota
        > exceeded
        >
        > Email : c.sibe@cario.fr
        > Errors : 2
        > Reason : 550 <c.sibe@cario.f r> ... recipient rejected
        >
        > Email : hohiojijoioh@cl ub-internet.fr
        > Errors : 8
        > Reason : 550 <hohiojijoioh@c lub-internet.fr>: Recipient address rejected:
        > User unknown in local recipient table
        >
        >[/color]


        Comment

        • ZeldorBlat

          #5
          Re: get all the email addresses from a text file


          Nico wrote:[color=blue]
          > "ZeldorBlat " <zeldorblat@gma il.com> a écrit dans le message de news:
          > 1143047047.2939 59.114180@g10g2 00...legr oups.com...
          >[color=green]
          > > What does the .txt file look like? (Please don't say HTML)[/color]
          >
          >
          > Well it looks like that :
          >
          >
          > Email : bois.massif@wan adoo.fr
          > Errors : 3
          > Reason : 550 <bois.massif@wa nadoo.fr>: Recipient address rejected: User
          > unknown
          >
          > Email : subaruclamp@aol .com
          > Errors : 2
          > Reason : 550 <subaruclamp@ao l.com>... User unknown
          >
          > Email : sylvie.ravise@i nfonie.fr
          > Errors : 64
          > Reason : 552 RCPT TO:<sylvie.ravi se@infonie.fr> Mailbox disk quota exceeded
          >
          > Email : c.sibe@cario.fr
          > Errors : 2
          > Reason : 550 <c.sibe@cario.f r> ... recipient rejected
          >
          > Email : hohiojijoioh@cl ub-internet.fr
          > Errors : 8
          > Reason : 550 <hohiojijoioh@c lub-internet.fr>: Recipient address rejected:
          > User unknown in local recipient table[/color]

          If you're confident about the format of the file, you can just do
          something like this:

          $fn = 'myfile.php';
          $lines = file($fn);

          $badAddresses = array();

          foreach($lines as $line)
          if(strpos($line , 'Email : ') === 0)
          $badAddresses[] = substr($line, 8);

          Of course that isn't very forgiving if one of the lines looks
          different, but it should work nonetheless.

          Comment

          Working...