Robert Richter Robert Richter - 5 months ago 12
jQuery Question

Is it possible to define in which folder my html form posts requests by using a select element?

Is it possible to define in which folder my HTML form posts requests by using a select element?

For example

<select class="dropdown" name="choose_folder">
<option selected value="post_in_the_folder_webdesign">Request Webdesign</option>
<option value="post_in_the_folder_private">Request private</option>
<option value="post_in_the_folder_anything">Anything else</option>
<option value="post_in_the_folder_spam">Spam</option>
</select>

FORM EMAIL ACCOUNT
-SELECT -ROUNDCUBE
-OPTION1=FoLDER1 -> IF THIS OPTION IS CHOSEN, THE EMAIL WILL APPEAR IN -> -FOLDER1
-OPTION2=FoLDER2 -> IF THIS OPTION IS CHOSEN, THE EMAIL WILL APPEAR IN -> -FOLDER2
-OPTION3=FoLDER3 -> IF THIS OPTION IS CHOSEN, THE EMAIL WILL APPEAR IN -> -FOLDER3
-OPTION4=FoLDER4 -> IF THIS OPTION IS CHOSEN, THE EMAIL WILL APPEAR IN -> -FOLDER4

Answer

I think you are confusing two things: form processing and email processing.

Form processing is the PHP code to process the form and do something after it has been sumitted. From what you are saying it seems like you are trying to send yourself an email.

Email processing is something your email provider (Gmail, Yahoo, etc.) will do once you receive an email. Depending on the rules you have setup (if rules are available with your email provider) incoming email will be processed one way or another.

Here is what I recommend you do: for each option selected, when processing the form on the server side, simply change or add something to the subject line of the email you are sending. Then in your email account set up an email processing rule to move the email in a different folder depending on the subject line.

Edit after first comment:

You could use a custom header starting with X-, which is just an extended mail header (I can't find the appropriate RFC but I remember it's in there). Here is an example of how you could send email:

$folder_to_use = 'blabla'; // Read this from the form, make sure it's a string

// Build custom header, don't forget the From: part
// Each header must be separated by a \r\n
$headers = "
    From: webmaster@yoursite.com\r\n
    Reply-To: webmaster@yoursite.com\r\n
    X-folder: $folder_to_use
";

// Send mail
mail ($address_to, 'Subject', $message_text, $headers);
Comments