Email with text file attachment
am 01.12.2007 01:18:50 von Yaw LimWhat is the easiest way to send an email with a text file attachment
(without MIME::LITE, etc)?
/Why Tea
What is the easiest way to send an email with a text file attachment
(without MIME::LITE, etc)?
/Why Tea
Why Tea wrote:
> What is the easiest way to send an email with a text file attachment
Your Question is Asked Frequently, please see "perldoc -q attachment".
> (without MIME::LITE, etc)?
Oh, in that case I would guess by re-implementing significant parts of
MIME::LITE from scratch in your program.
jue
> > (without MIME::LITE, etc)?
>
> Oh, in that case I would guess by re-implementing significant parts of
> MIME::LITE from scratch in your program.
Oh, not really. I have seen bits and pieces about using sendmail or
similar. I'm only after a minimal way of sending an email with a text
attachment without any additional package.
On Nov 30, 8:12 pm, Why Tea
> > > (without MIME::LITE, etc)?
>
> > Oh, in that case I would guess by re-implementing significant parts of
> > MIME::LITE from scratch in your program.
>
> Oh, not really. I have seen bits and pieces about using sendmail or
> similar. I'm only after a minimal way of sending an email with a text
> attachment without any additional package.
This is not the method I'd use, because I'd be using MIME::Lite, but
you could do a system call to uuencode (to encode your file
attachment) and pass it to the mail command.
man uuencode
man mail
On Fri, 30 Nov 2007 20:30:41 -0800, Ron Bergin wrote:
> This is not the method I'd use, because I'd be using MIME::Lite, but you
> could do a system call to uuencode (to encode your file attachment) and
> pass it to the mail command.
I've used this method often and it works like a charm.
M4
On Dec 1, 3:57 am, Martijn Lievaart
> On Fri, 30 Nov 2007 20:30:41 -0800, Ron Bergin wrote:
> > This is not the method I'd use, because I'd be using MIME::Lite, but you
> > could do a system call to uuencode (to encode your file attachment) and
> > pass it to the mail command.
>
> I've used this method often and it works like a charm.
>
> M4
Yes, it does work, but it's not as flexible and it unnecessarily
spawns additional processes. This method of sending an email is not
"not very Perlish"; it's most often done in shell scripts. So, do you
want to write a shell script or perl script?
On Sat, 01 Dec 2007 09:25:54 -0800, Ron Bergin wrote:
> On Dec 1, 3:57 am, Martijn Lievaart
>> On Fri, 30 Nov 2007 20:30:41 -0800, Ron Bergin wrote:
>> > This is not the method I'd use, because I'd be using MIME::Lite, but
>> > you could do a system call to uuencode (to encode your file
>> > attachment) and pass it to the mail command.
>>
>> I've used this method often and it works like a charm.
>>
>> M4
>
> Yes, it does work, but it's not as flexible and it unnecessarily spawns
> additional processes. This method of sending an email is not "not very
> Perlish"; it's most often done in shell scripts. So, do you want to
> write a shell script or perl script?
Sometimes I want to write a script that works without installing
additional modules. In medical environments it is simpler to get one
script validated than a script plus installing new modules.
Besides, Perl is a very good glue language, often better suited than the
shell. So yes, maybe I just want to write a shell script and do it in
Perl.
M4
> > Yes, it does work, but it's not as flexible and it unnecessarily spawns
> > additional processes. This method of sending an email is not "not very
> > Perlish"; it's most often done in shell scripts. So, do you want to
> > write a shell script or perl script?
>
> Sometimes I want to write a script that works without installing
> additional modules. In medical environments it is simpler to get one
> script validated than a script plus installing new modules.
This is exactly my point although I'm not in the medical field.
> Besides, Perl is a very good glue language, often better suited than the
> shell. So yes, maybe I just want to write a shell script and do it in
> Perl.
Can anyone share a bare minimum plain vanilla Perl script that glues a
few Unix commands to send an email with a text file?
Quoth Why Tea
>
> Can anyone share a bare minimum plain vanilla Perl script that glues a
> few Unix commands to send an email with a text file?
#!/usr/bin/perl
open my $MAIL, '-|',
mutt =>
-a => '/a/text/file',
-s => 'Test email',
'foo@bar.com'
or die "can't fork mutt: $!";
print $MAIL "Hello world!\n";
close $MAIL or die "sending mail failed: $!";
__END__
Ben