or directly with sendmail:use strict; use Mail::Mailer; my $mailer = Mail::Mailer->new(); $mailer->open({ From => $from_address, To => $to_address, Subject => $subject, }) or die "Can't open: $!\n"; print $mailer $body; $mailer->close();
This was taken directly from the Perl Cookbook page 651. Go buy it!open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or die "Can't fork for sendmail: $!\n"; print SENDMAIL <<"EOF"; From: User Originating Mail <me\@host> To: Final Destination <you\@otherhost> Subject: A relevant subject line Body of the message goes here, in as many lines as you like. EOF close(SENDMAIL) or warn "sendmail didn't close nicely";
The first one uses the CPAN module Mail::Mailer, there are lot's of other CPAN modules that send mail for you, such as Mail::Sendmail.
Use the second method __ONLY__ if you can't install CPAN modules on your school's computer, which you probably can't. Since this looks like a homework question, please do some studying and don't just cargo cut-n-hack. You'll probably be tested on this anyway. :)
Jeff
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR F--F--F--F--F--F--F--F-- (the triplet paradiddle)
In reply to (jeffa - sending mail) Re: Help
by jeffa
in thread how do I issue e-mail using perl? (was:Help)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |