Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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é

In reply to Sending HTML email and a slightly related 500 error by Foncé

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found