Loading ...
Sorry, an error occurred while loading the content.
 

RE: [PBML] How to remove headers from the mails

Expand Messages
  • Oliver Manickum
    Sure, just open your email message like a normal text file (*it should be in that style as per rfc s*) and read in line by line eg
    Message 1 of 2 , Jan 5, 2001
      Sure,

      just open your email message like a normal text file (*it should be in that
      style as per rfc's*) and read in line by line

      eg
      open(EMAIL,"/usr/home/mail/mymail") || die "cannot open mail";
      $outmail = "";

      while ($linein = <EMAIL>) {
      if (($linein =~ /^From/i) || ($linein =~ /^To/i)) {
      $outmail .= $linein."\n";;
      }
      if (($linein =~ /^Subject/) || ($isGood == 1)) {
      # is good coz we know that we want everything after the subject line (*as
      it
      # contains the body of the mail
      $outmail .= $linein."\n";
      $isGood = 1;
      }
      }

      close(EMAIL);
      open(OTMAIL,"/usr/home/mail/mynewmail") || die "Canoot open mail";
      print OTMAIL $outmail;
      close(OTMAIL);

      -- Olly




      -----Original Message-----
      From: Rahul Jain [mailto:rahul_jain@...]
      Sent: 05 January 2001 04:01
      To: perl-beginner@egroups.com
      Subject: [PBML] How to remove headers from the mails


      Hi all,

      I have a text file containing all the mails from my mailbox one after
      the other.

      Apart from the content of the mail, these mails also contain a lot of
      headers and other
      information ( sometime upto 30-40 lines of it) which I don't require.

      I wish to write a perl script which will strip off all these headers
      such that only the following remain

      From:
      Date:
      Subject:
      Content

      Is there any way to do this.

      I heard that there is an existing unix utility available which does
      this. If so, then can anyone please tell
      me about it.

      Thanks in advance

      Rahul
    Your message has been successfully submitted and would be delivered to recipients shortly.