Announcement

Collapse
No announcement yet.

Multiple Mail Form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Mail Form

    If I have a single form, is it possible for the visitor to choose where it is sent? As in, selecting a member of Staff from a dropdown menu which subsequently sends that form to that e-mail address? And is it possible to have the form sent to multiple addresses at once?

  • #2
    Re: Multiple Mail Form

    Yes, but you would have to add additional security features. As it is now the email address it is sent to is hard coded. If you change that to being a field submitted by the user (which is what it would be if you make it a drop down menu), you will have to check that submitted data to make sure multiple email address weren't entered. It could very easily be used to send spam if you don't do that check.

    And sending to multiple address is very simple, you just separate the emails by a comma.
    PHP Code:
    $mailto "email1@domain.com,email2@domain.com,email3@domain.com"
    That being said, were you wanting to send an email to multiple people in the drop down menu, or one from the menu, and the address hard coded in the script.

    For sending the email to a specified address, create the dropdown menu, and set the "name" attribute for the dropdown menu to something like "email_to", and for each selection of the menu set the "value" to the email address

    And then in the script set
    PHP Code:
    $mailto $_POST['email_to']; 
    And do a check using this function

    PHP Code:
    function valid_email($check)

        return 
    preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$check); 
    }

    if(!
    valid_email($mailto))
    die(
    "Invalid email address"); 

    I hope that helps

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment


    • #3
      Re: Multiple Mail Form

      Thanks heaps for that. It all makes sense so I'll test it out.

      Comment

      Working...
      X