http://qs1969.pair.com?node_id=21231


in reply to How to send email

It looks like you are missing the leading quotation mark in your system call. Running perl -wc on your code will help you find small errors like this.

Update: I ran perl -wc on this code and it didn't spit out any errors, so it wouldn't have helped you in this case. It's still a good idea to use it though :)

I would try and shy away from writing the mail to a temp file though; it will be a headache for you if the directory or file permissions ever get changed. I would probably do something like:

open (MAIL, "|/usr/sbin/sendmail -t -oi -em") || die "Couldn't open sendmail: $!"; print MAIL <<EOM; To: me\@mycompany.com From: myscript\@mycompany.com Subject: Some subject $reportdata EOM close (MAIL);