send e-mail and attachment

T

ty

Could anyone tell me how to send e-mail and attachment (a text file) by
Perl?

I used codes like these:

$to="takashiyyy\@yahoo.com";
$from ="anotherAdress\@yahoo.com";
$subject = "test";
$content = "this is a test";

open (MAIL, "|/usr/sbin/sendmail -t");

print MAIL "TO: $to \nFrom: $from: \n";
print MAIL "Subject: $subject \n";
print MAIL "$content \n";
close(MAIL);


but how can I attache a file (text file)?

thank you.

takashi
 
M

Michael Budash

ty <[email protected]> said:
Could anyone tell me how to send e-mail and attachment (a text file) by
Perl?

I used codes like these:

$to="takashiyyy\@yahoo.com";
$from ="anotherAdress\@yahoo.com";
$subject = "test";
$content = "this is a test";

open (MAIL, "|/usr/sbin/sendmail -t");

print MAIL "TO: $to \nFrom: $from: \n";
print MAIL "Subject: $subject \n";
print MAIL "$content \n";
close(MAIL);


but how can I attache a file (text file)?

thank you.

takashi

use MIME::Lite;
 
T

Tore Aursand

Could anyone tell me how to send e-mail and attachment (a text file) by
Perl?

You should take a look related modules on CPAN, preferrably MIME::Lite.
I used codes like these:

$to="takashiyyy\@yahoo.com";
$from ="anotherAdress\@yahoo.com";
$subject = "test";
$content = "this is a test";

Hint: Use - whenever possible - "single" apostrophes (can't remember the
correct name for it now). That way you don't have to think about escaping
special characters when there aren't any;

my $to = '(e-mail address removed)';
my $from = '(e-mail address removed)';
open (MAIL, "|/usr/sbin/sendmail -t");

What happens when something goes wrong? What does your script do? Nada?
Like nothing wrong ever happened? That's a bad idea.

Have a look, as I said, at MIME::Lite. It's a nice module.
 
T

Tintin

ty said:
Could anyone tell me how to send e-mail and attachment (a text file) by
Perl?

I used codes like these:

$to="takashiyyy\@yahoo.com";
$from ="anotherAdress\@yahoo.com";
$subject = "test";
$content = "this is a test";

open (MAIL, "|/usr/sbin/sendmail -t");

print MAIL "TO: $to \nFrom: $from: \n";
print MAIL "Subject: $subject \n";
print MAIL "$content \n";
close(MAIL);


but how can I attache a file (text file)?

MIME::Lite makes this simple for you.
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top