in reply to Setting subject with Net::SMTP

hola. there sure is a function, and it's in Net::SMTP.

the OP's question can be answered without a goto MIME::Lite - unless you need to attach stuff. not that MIME::Lite is not a fine module. however, IMHO Net::SMTP is absolutely fine & dandy for subject setting.

the following very small module wraps it and should allow you to use it relatively painlessly. of course there should be error handling etc etc. left as an exercise for the reader...

# a simple module which uses Net::SMTP to mail the contents # of a text file to a list of users. and with a # subject too! note minor spoofing. adjust to taste. package wmail; use Net::SMTP; sub mailfile{ my $smtpserver = 'server here plz'; my $file = shift; die "no file" unless $file; my $rcptsref = shift; die "no recipients" unless ref $rcptsref; my $subj = shift or "oops"; my @recipients = @{$rcptsref}; my $oldRs = $/; undef $/; open SOURCE, "$file" or die "can't open file $!"; my $totalcontents = <SOURCE>; close SOURCE; my $smtp = Net::SMTP; $smtp = Net::SMTP->new($smtpserver); $smtp->mail("informant"); $smtp->to(@recipients); $smtp->data(); my $subjectline = "Subject: " . $subj . "\n"; $smtp->datasend($subjectline); $smtp->datasend("\n"); $smtp->datasend($totalcontents); $smtp->dataend(); # print $smtp->domain, "\n"; $smtp->quit; } 1;
save that to say, wmail.pm, use in the following manner

use wmail; @recipients = ('your rcpts here'); wmail::mailfile("myfile", \@recipients, "mysubject");
...wufnik

-- in the world of the mules there are no rules --