in reply to Sending HTML-formatted mail to a list

Most of your problems will go away if you chomp each line as you read it from the address file. The closing \n on each address, which chomp will remove, is currently combining with the \n in your To: line to end the message header. I think. So:

while(<MAILIST>) { chomp; push (@address, $_); }

But on the other hand, all of your (mailing) problems will go away if you use something like Mail::Sendmail instead. It will cheerfully handle multiple addresses and whatever content-type you like. Or better still, set up a mailing list and just send a single message to that...

Your other problem is in the message itself:

print MAIL '$headers';

The single quotes mean that the variable is not interpolated, so you are literally printing the dollar sign followed by 'headers'. If you want the contents of the variable, the string must be enclosed in double-quotes or an equivalent.

But you don't need quotes anyway, in this case: print MAIL $headers; will do just fine.

ps. mutter use strict mutter taint-checking mutter mutter hardcoded sendmail path mutter.

 

update: one more thing. this isn't right:

$message = $q->param( 'html_message' || '' );

It works, but it isn't performing the test you want. translated, it would read something like 'the input parameter whose name is 'html_message', or if 'html_message' is false, the one whose name is empty'. But 'html_message' is always true, as is any other unempty string except '0', so you are (fortunately) never moving on to the second alternative. I think you meant:

$message = $q->param( 'html_message' ) || '';

But you don't really need the || '' anyway: $message will be empty with or without it.