This is essentially a two-parter.
1. I've got a form that allows our salesmen to simply fill it out and then click send and it sends a copy to each the boss and the secretary. It also shoots a copy back at the salesman. The email addresses of the boss and secretary (and whoever else wants one, such as the owner) are stored in
@cc and the email address of the salesman who is using the form comes from
$FORM{user}. First problem is this: how can I change the following code so I can send an HTML email rather than plain text?
# Open The Mail
open (MAIL, "|$mailprog -t") || &safe_die("Can't open $mailprog!\n");
print MAIL "From: $rn\n";
print MAIL "Reply-To: $uname\n";
print MAIL "To: $uname\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "Below is the information submitted on $date\n";
print MAIL "------------------------------\n\n";
print MAIL qq~ *** omitting the irrelevant body stuff *** ~
close (MAIL);
2. The other problem is that, although with the code I'm posting below not all of the emails send. Then I get a 500 error instead of the "message sent" page to which it is supposed to go. Also, I'd like to get rid of the sloppiness of having two mail send routines since there's one for the array and one for the salesman (which is selected on the form). If I can get the array to work, I can just add to address from the form to it and use one routine only. Here's the relevant code:
$count = 0;
foreach (@cc) {
$count += 1;
# Open The Mail
open (MAIL, "|$mailprog -t") || &safe_die("Can't open $mailprog!\n");
print MAIL "From: $rn\n";
print MAIL "Reply-To: $uname\n";
print MAIL "To: $cc[$count]\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "Below is the information submitted on $date\n";
print MAIL "-----------------------------\n\n";
print MAIL qq~ *** more irrelevant HTML *** ~
close (MAIL);
}
I was thinking something along the lines of this:
foreach (@cc) {
$count += 1;
# Open The Mail
open (MAIL, "|$mailprog -t") || &safe_die("Can't open $mailprog!\n");
print MAIL "From: $rn\n";
print MAIL "Reply-To: $uname\n";
print MAIL "To: $cc[$_]\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL "Below is the information submitted on $date\n";
print MAIL "-----------------------------\n\n";
print MAIL qq~ *** more irrelevant HTML *** ~
close (MAIL);
}
...but that doesn't work. I'm not entirely sure if
$_ is the number or the actual address being stored in the array, so...help, please?
Foncé
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.