Solved

Multiple recipients in FormMail

Posted on 2000-04-08
6
750 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now