Monks,
I have a situation where I'm looping through a list to send an email out. There are 9 possible email addresses, even though 99% of the time only the $email variable exists. My logs show errors every time an email is sent. It's as if this loop is trying to send to the other 8 $pscemail vars even though they are empty.
@email = ($email,$pscemail1,$pscemail2,$pscemail3,$pscemail4,$pscemail
+5,$pscemail6,$pscemail7,$pscemail8);
foreach $address (@email) {
open (HTMLMAIL, "|$sendmail $address") || die "Can't o
+pen $sendmail!\n";
print HTMLMAIL "From: $name <$adminemail>\n";
#print HTMLMAIL "Reply-to: $fromname <$fromemail>\n";
print HTMLMAIL "To: $address\n";
print HTMLMAIL "Subject: $subject\n";
print HTMLMAIL "Content-type: text/html\n";
Print HTMLMAIL "blah blah blah";
close (HTMLMAIL);
}
I'm not sure how to solve this. I assumed it simply wouldn't send if the vars were empty.
This is the error I'm getting 7x:
sendmail.postfix: fatal: Recipient addresses must be specified on the command line or via the -t option:
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.