It's my first time to use sendmail. I want to my script to send a mail to [EMAIL PROTECTED] or whoever is in the To: line. The script warns:"No recipient name found in the header" and dies, even though there's a recipient. I'm puzzled.
####################################### #!/usr/bin/perl -w
use strict;
mail_users();
sub mail_users{
open(MAILPROG, "|/usr/sbin/sendmail -oi -t") || die "Can't open sendmail: $!\n";
print MAILPROG <<"END_MAIL";
From: ftp_update.pl
To: root <[EMAIL PROTECTED]>
Subject: Software updates
Hello
You may copy and paste this at the shell-prompt to test dependencies:
You may also use this command to install the Packages:
END_MAIL
close(MAILPROG);
#################################################
Well obviously it isn't that you are missing a curly brace in your post as that gives a syntax error. Your example brings up two very good points,
1) why I don't drool over using heredocs as much as some of the other Perl gurus, too much can go wrong too fast,
2) why you should not mess with sending e-mail in a manual way such as piping a poorly made message into an incredibly complex program such as sendmail, but should instead employ one of the plethora of modules available from your local CPAN distributor.
I *believe* the reason why your message is failing is because the header is not being constructed properly, because the header lines start with a 'tab' rather than being left aligned as they are supposed to be. I realize that you did so to follow indenting standards, an excellent idea, one that wouldn't affect HTML or the like, but has a large impact on the mail standards, which naturally you could have avoided had you used a module because in that case you were not likely to use a heredoc.
That was a tough one, and yes I am a big geek who has worked on e-mail systems too long if I can spot that one.... HTH,
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>