Solved

Multiple recipients in FormMail

Posted on 2000-04-08
6
756 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending email via Perl on Windows 3 138
Uploading Binary Data using Perl 5 83
perl script help 12 104
PERL - Find newest folder 12 118
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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

920 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