Email with text file attachment

W

Why Tea

What is the easiest way to send an email with a text file attachment
(without MIME::LITE, etc)?

/Why Tea
 
J

Jürgen Exner

Why said:
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
 
W

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.
 
R

Ron Bergin

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
 
M

Martijn Lievaart

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
 
R

Ron Bergin

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?
 
M

Martijn Lievaart

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
 
W

Why Tea

Yes, it does work, but it's not as flexible and it unnecessarily spawns
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?
 
B

Ben Morrow

Quoth Why Tea said:
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',
'(e-mail address removed)'
or die "can't fork mutt: $!";

print $MAIL "Hello world!\n";
close $MAIL or die "sending mail failed: $!";

__END__

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,206
Messages
2,571,071
Members
47,678
Latest member
Aniruddha Das

Latest Threads

Top