Page 1 of 6 123 ... LastLast
Results 1 to 10 of 52

Thread: TO and CC plus multiple option values.

  1. #1
    Join Date
    Feb 2013
    Posts
    37

    Default TO and CC plus multiple option values.

    Can the formmail.php send to multiple email accounts TO & CC based on which option value is selected from a drop down list? If so where in the formmail.php would the info go?

    Do I need what you see here in the input name statement?

    <input name="recipient" type="hidden" value="name1@domain.com,name2@domain.com,name3@domain.com,name4@domain.com,name5@domain.com,name6@domain.com" />

    <option value="Public Works">Public Works</option>
    <option value="Construction Office">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police & Fire">Police & Fire</option>
    <option value="Administration & Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>

    For each value (department) when the user selects one of the choices from the drop down, two people are to get the results from the form. TO and CC.

  2. #2
    Join Date
    May 2008
    Posts
    1,291

    Default Re: TO and CC plus multiple option values.

    Hi,

    One way to do it would be to use the department selection field and name it "recipients", then provide the email addresses for that department in the "value" for each option. The code would look something like this:

    HTML Code:
    <select name="recipients">
    <option value="email1@company.com,email2@company.com">Public Works</option>
    <option value="email3@company.com,email4@company.com">Construction Office</option>
    <option value="email5@comopany.com,email6@company.com">Economic Development</option>
    <option value="email7@company.com,email8@company.com">Police & Fire</option>
    <option value="email9@company.com,email10@company.com">Administration & Other</option>
    <option value="email11@company.com,email12@company.com">Website Issues</option></select>
    The only problem with this method is that it puts the email addresses in the viewable source code of the html. A better method would be to use a server side INI file and do something like this:

    Code:
    [email_addresses] 
    
    Public Works = "email1@company.com,email2@company.com" 
    Construction = "email3@company.com,email4@company.com"
    Economic Development = "email5@company.com,email6@company.com"
    Police Fire = "email7@company.com,email8@company.com"
    Administration Other = "email9@company.com,email10@company.com"
    Website Issues = "email11@company.com,email12@company.com"
    Then in your form you would put:

    HTML Code:
    <select name="recipients">
    <option value="Public Works">Public Works</option>
    <option value="Construction">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police Fire">Police & Fire</option>
    <option value="Administration Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>
    </select>
    The following link explains how to configure the INI file which is just a plaintext file created in Notepad that's uploaded to the server:

    http://www.tectite.com/fmhowto/inifile.php

    ginger

  3. #3
    Join Date
    Feb 2013
    Posts
    37

    Default Re: TO and CC plus multiple option values.

    Thank you very very much. If I have anymore question or don't understand something I'll reply.

    Otherwise how do I add this type of domain to this

    EMAIL_NAME."@yourhost\.com$"

    user@woodbury.nj.us

  4. #4
    Join Date
    May 2008
    Posts
    1,291

    Default Re: TO and CC plus multiple option values.

    As far as I know the following should work:

    Code:
    $TARGET_EMAIL = array(EMAIL_NAME."@woodbury\.nj\.us$");
    ginger

  5. #5
    Join Date
    Feb 2013
    Posts
    37

    Default Re: TO and CC plus multiple option values.

    Ok, so I did this to my html file where the drop don list is

    <select class="select valid" name="Select which dept. you would like to contact." id="Select which dept. you would like to contact.">
    <select name="recipients">
    <option value="">Select One</option>
    <option value="Public Works">Public Works</option>
    <option value="Construction Office">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police & Fire">Police & Fire</option>
    <option value="Administration & Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>
    </select>

    Then I created the ini file as you said

    [email_addresses]


    Public Works = "TO email address,CC email address"
    and the others.

    What I don't understand is what has to be changed in the formmail.php if anything and where in the php file do I tell it to look for the ini file?






    Quote Originally Posted by ginger23 View Post
    Hi,

    One way to do it would be to use the department selection field and name it "recipients", then provide the email addresses for that department in the "value" for each option. The code would look something like this:

    HTML Code:
    <select name="recipients">
    <option value="email1@company.com,email2@company.com">Public Works</option>
    <option value="email3@company.com,email4@company.com">Construction Office</option>
    <option value="email5@comopany.com,email6@company.com">Economic Development</option>
    <option value="email7@company.com,email8@company.com">Police & Fire</option>
    <option value="email9@company.com,email10@company.com">Administration & Other</option>
    <option value="email11@company.com,email12@company.com">Website Issues</option></select>
    The only problem with this method is that it puts the email addresses in the viewable source code of the html. A better method would be to use a server side INI file and do something like this:

    Code:
    [email_addresses] 
    
    Public Works = "email1@company.com,email2@company.com" 
    Construction = "email3@company.com,email4@company.com"
    Economic Development = "email5@company.com,email6@company.com"
    Police Fire = "email7@company.com,email8@company.com"
    Administration Other = "email9@company.com,email10@company.com"
    Website Issues = "email11@company.com,email12@company.com"
    Then in your form you would put:

    HTML Code:
    <select name="recipients">
    <option value="Public Works">Public Works</option>
    <option value="Construction">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police Fire">Police & Fire</option>
    <option value="Administration Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>
    </select>
    The following link explains how to configure the INI file which is just a plaintext file created in Notepad that's uploaded to the server:

    http://www.tectite.com/fmhowto/inifile.php

    ginger

  6. #6
    Join Date
    Feb 2013
    Posts
    37

    Default Re: TO and CC plus multiple option values.

    Is it required to have all the email address's the TO's and the CC's in the $TARGET_EMAIL section of the php file? That means all 12.


    Quote Originally Posted by scottbwc24 View Post
    Ok, so I did this to my html file where the drop don list is

    <select class="select valid" name="Select which dept. you would like to contact." id="Select which dept. you would like to contact.">
    <select name="recipients">
    <option value="">Select One</option>
    <option value="Public Works">Public Works</option>
    <option value="Construction Office">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police & Fire">Police & Fire</option>
    <option value="Administration & Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>
    </select>

    Then I created the ini file as you said

    [email_addresses]


    Public Works = "TO email address,CC email address"
    and the others.

    What I don't understand is what has to be changed in the formmail.php if anything and where in the php file do I tell it to look for the ini file?

  7. #7
    Join Date
    May 2008
    Posts
    1,291

    Default Re: TO and CC plus multiple option values.

    You have two <select> tags and should only have the one with the name "recipients". Then you can create a label that would tell the user to select a department.

    HTML Code:
    Please select the department you'd like to contact: <select class="select valid" name="recipients" id="recipients">
    You'd probably want to use derive_fields then if you need to display the department name in your email results.

    HTML Code:
    <input type="hidden" name="derive_fields" value="Department=recipients">
    (Hopefully that will give you the department name value in the recipients field and not the email address.)

    Then in the php script you'll need to set the value of "$FORM_INI_FILE" which is a server path to where the ini file is located on the server. (Preferably it should be stored above the root so it's not accessible to the public.) You can get the server path to the script by running testalert. Put this in your browser: http://yourdomain.com/path-to-formmail.php?testalert=1 . You should then receive an email with the server path which you can adjust according to where you've placed your INI file. (This email will go to the email address you specified in the $DEF_ALERT setting in formmail.php).



    Code:
    $FORM_INI_FILE = "/path/to/formmail.ini";
    ginger
    Last edited by ginger23; 16-Feb-2013 at 04:22 PM.

  8. #8
    Join Date
    May 2008
    Posts
    1,291

    Default Re: TO and CC plus multiple option values.

    Quote Originally Posted by scottbwc24 View Post
    Is it required to have all the email address's the TO's and the CC's in the $TARGET_EMAIL section of the php file? That means all 12.
    If they're all at the same domain, then just using the following should work:

    Code:
    $TARGET_EMAIL = array(EMAIL_NAME."@woodbury\.nj\.us$");
    If they're not all at that domain, then they'll need to be listed individually in the format shown in example #4 near the bottom of this page:

    http://www.tectite.com/fmdoc/target_email.php

    ginger

  9. #9
    Join Date
    Feb 2013
    Posts
    37

    Default Re: TO and CC plus multiple option values.

    Ok so in my html file I have this. Is this all correct?

    I already added the ini file to the server and set the path in the formmail.php file.

    <form action="/cgi-bin/formmail.php" method="POST">
    <input type="hidden" name="derive_fields" value="Department=recipients">

    <select name="recipients" id="recipients" class="select valid" name="Select which dept. you would like to contact." id="Select which dept. you would like to contact.">
    <option value="">Select One</option>
    <option value="Public Works">Public Works</option>
    <option value="Construction Office">Construction Office</option>
    <option value="Economic Development">Economic Development</option>
    <option value="Police & Fire">Police & Fire</option>
    <option value="Administration & Other">Administration & Other</option>
    <option value="Website Issues">Website Issues</option>
    </select>

  10. #10
    Join Date
    May 2008
    Posts
    1,291

    Default Re: TO and CC plus multiple option values.

    I already added the ini file to the server and set the path in the formmail.php file.
    Make sure that you've specified a "server path" which usually starts with something like /home/user ...

    As for your form code, you don't want two Names and two IDs in the same select tag. Remove this from the select tag:

    name="Select which dept. you would like to contact." id="Select which dept. you would like to contact.

    (I think I'd remove the ampersands from your email aliases if I were you. They may or may not cause problems. Put "and" if you have to.) You can still put the ampersand in the portion of the option tag that displays to the user.

    ginger

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I pass multiple checkbox values?
    By alinsmeier in forum Community Support
    Replies: 4
    Last Post: 22-Feb-2013, 03:43 PM
  2. How to Use the file_names option
    By Frank in forum Community Support
    Replies: 5
    Last Post: 20-Oct-2010, 10:46 PM
  3. Multiple emails in autoresponse from field values?
    By rodev in forum Community Support
    Replies: 5
    Last Post: 30-Aug-2006, 12:19 AM
  4. multiple selection for option group?
    By sutra in forum FormMail Subscription Support
    Replies: 2
    Last Post: 27-Aug-2005, 08:35 AM
  5. Exclude Option
    By zeuseason in forum FormMail Subscription Support
    Replies: 2
    Last Post: 16-Sep-2004, 08:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •