Solved

Multiple recipients in FormMail

Posted on 2000-04-08
6
757 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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