[olug] RE: How to MIME encode
Sam Tetherow
tetherow at nicusa.com
Tue Oct 28 14:47:17 UTC 2003
In perl
use MIME::Entity;
$messg=build MIME::Entity From => $from_address,
To => $to_address,
Subject => $subject,
Data => $body_text;
attach $messg Path => $attachment_filename,
Type => $mime_type_of_attachment,
Encoding => "base64";
open(MAIL, "| /usr/sbin/sendmail -t -i") | die "Could not open sendmail:
$!\n";
$messg->print(\*MAIL);
close(MAIL);
You can call attach multiple times to attach more than one file.
You can also send via some other mechanism, say Net::SMTP, by replacing
the last 3 lines.
Bob McCoy wrote:
> In this case, the originating box is a Linux box. I don't know what the
> destination box is. The original script took a bunch of files, tarred
> it up, uuencoded it, and mailed it to a recipient. Using a client like
> Outlook, I was able to save the attachment. However, now I need to mail
> it to another system that strips the attachments off and saves them.
>>From a high level, the script looked like:
>
> tar | uuencode | mail
>
> Now it needs to look like:
>
> tar | (mime encode) | mail
>
> I just don't know what goes in the place of (mime encode) on the command
> line.
>
> I may take a look at the Perl solution Jay recommended since I have the
> option of running Perl on the source machine. I looked at that solution
> and it seemed pretty elegant.
>
> Bob
>
>
> -----Original Message-----
> From: omaha.pm.knitter at recursor.net
> [mailto:omaha.pm.knitter at recursor.net]
> Sent: Monday, October 27, 2003 2:20 PM
> To: "Jay Hannah - jay at jays.net, Bob McCoy <bob at mccoy.net>"@tconl.com
> Cc: olug at olug.org; omaha-list at happyfunball.pm.org
> Subject: Re: How to MIME encode
>
>
> At 01:55 PM 10/27/2003 -0600, Jay Hannah - jay at jays.net wrote:
>
>>Quoting Bob McCoy <bob at mccoy.net>:
>>
>>>Does anyone know how to MIME encode a binary file for emailing? In
>>>the past I've used uuencoding and that worked fine. However, I'm now
>
>
>>>mailing this file to another service that only seems to understand
>>>MIME encoding. Here is the original code snippet:
>>>
>
>
> How you do it depends on the platform you're on, and how they retrieve
> it depends on what they're on (I assume Windows on their side.) Elm
> handles mime encoding pretty well and I hear Pine does too.
>
> If the file's not too large, you could try just sending as plain ascii
> text with a .txt extension, and let them change the extension back to
> whatever after they've downloaded it.
>
> You might try q-print http://www.fourmilab.ch/webtools/qprint/ or
> m-pack if you're on a Mac.
>
> If it was me, I'd upload the file to a web page and send them the URL to
> download it.
>
> If all else fails, zip it.
>
> -Sidney
>
>
>
>
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
>
--
------------------------------------------------------------------------
Sam Tetherow tetherow at nicusa.com
Director of Development
NIC Labs (PSSG) http://www.nicusa.com
More information about the OLUG
mailing list