Solved

Multiple recipients in FormMail

Posted on 2000-04-08
6
762 Views
Last Modified: 2008-03-03
I'm trying to configure FormMail to send an email to up to 5 different email addresses that are entered in a form by a visitor to my website. I named the variables email1 email2 email3 email4 and email5

I seem to be able to get it to mail to one of the addresses but not the other. Here is the part of the script that I need worked on (I think)

    print MAIL "To: $Config{'email1'}\n";
    print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

How can I get the script to email all 5 recipients? It is also possible that the person who fills out the form might only fill in one or two email addresses. I don't know if that will present any problems.

Thanks in advance for any help.

Tim
0
Comment
Question by:timshank
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2697277
what is FormMail, what is $Config{'email1'} and what went wrong when you couldn't get mail to the other address?
0
 
LVL 2

Accepted Solution

by:
tpryor earned 200 total points
ID: 2697882
Well there will be a lot of guessing going on but here goes.


- if the user filling out the form is specifying the email address ( up to 5 ) to mail to.

- and each email address is on its own field ( meaning it has its own var name ie "email1" in the form "name=email1")

- and those values are stored by name in the hash %Config

then do this...

      # make an array with the mail to var names ie email1, email2, email3 etc
      # in FormMail, anywhere above the part of code that mails, in the same
      # block
      
      @email_to_var_names = ( email1, email2, email3, email4, email5 );
      
      # now loop through them and mail
      
      foreach $email_to ( @email_to_var_names ) {
      
            $email_to = $Config{"$email_to"};
            next if( ! $email_to );    # If no value submitted by user get next
          print MAIL "To: $email_to\n";
          print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
          
          # add rest of email code
          
    } # end of email loop
0
 
LVL 2

Expert Comment

by:serg111
ID: 2698356
Make it simple:


print MAIL "To: $Config{'email1'}\n";
print MAIL "CC: $Config{'email2'} $Config{'email3'} $Config{'email4'} $Config{'email5'} $Config{'email6'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

It will send carbon copies (CC) to any number of addresses
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:tpryor
ID: 2698487
well it doesnt check if it actually has a value
0
 
LVL 84

Expert Comment

by:ozo
ID: 2698536
which may be ok as long as Config{email1} actually has a value
tpryor, if you look at @email_to_var_names after running your routine, you may find that it had an unintended side effect.
you may prefer something like
foreach $email_to ( @Config{email_to_var_names} ){
or
foreach $email_to ( @Config{'email1'..'email5'} ){
0
 

Expert Comment

by:gregreeve
ID: 2730145
I have just done this so I know it works:

On the To: line to send to multiple recipients the e-mail addresses must be separated by a comma.  Its that simple.  So a To: line would look like:

print MAIL "To: $Config{'email1'}, $Config{'email2'}, $Config{'email3'}, $Config{'email4'}, $Config{'email5'}, $Config{'email6'}\n";

Problem solved.


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question