in reply to email parsing problem?

You are parsing data incorrectly (try long lines or lines starting with "--" to get a bunch of email-control characters.

Use Mail::Message to get attachments out of the email and manipulate mime types better.

use Mail::Message; my $fromline = <STDIN>; my $msg = Mail::Message->read(\*STDIN); if($msg->isMultipart) { for($msg->body->parts) { open(my $tofile,">/tmp/filename") or die "Error opening tmpfile: $!"; $_->print($tofile); close $tofile; # print } }

As you might guess, multiple attachments are also handled correctly.

Replies are listed 'Best First'.
Re: Re: email parsing problem?
by Octavian (Monk) on Dec 10, 2003 at 20:35 UTC
    That looks like a pretty good idea, we dont have Mail::Message installed though...so its not gonna help..I will see about getting that module, but making a change to our version of perl takes forever (yes, I work for the government)
    the only related modules we do have are (I searched for MIME and Mail):
    MIME::Base64 MIME::QuotedPrint Mail::Sender
      *sigh* I work for an extension of a State government. I feel your pain.

      At times like this, the adage "it's easier to apologize than get permission" might serve you well. YMMV.

      If things get any worse, I'll have to ask you to stop helping me.