-1

Venerable masters of all things code, I am a simple graphic (not even web) designer, struggling to creating a working mailing script.

So far, I managed to do it with basic HTML and a mailto function, but it needs to happen server-side, so, I am guessing PHP is my best bet.

Here's what I have so far:

<form action="mailto:?subject=Hello" method="POST" enctype="text/plain">
<input type="checkbox" name="Entry1" value="URL1">
<input type="checkbox" name="Entry2" value="URL2">
<input type="checkbox" name="Entry3" value="URL3">
<input type="checkbox" name="Entry4" value="URL4">
<label for="name">Name</label><input type="text" id="name" name="name" placeholder="Your Name">
<label for="email">Email(Required)</label><input type="text" id="email" name="email" placeholder="john_doe@example.com" required class="inputfield">
<input type="submit" id="search-submit" value="">
</form>

What I am trying to accomplish:

  1. An email to be sent from abc@email.com "email" field and a CC to 321@email.com
  2. With a message and Values (URL1,URL2...) from checked Boxes (Entry1,Entry2...)
  3. If successful, redirect to a thank you page.
  • can you post your email sending code (using mail() function maybe ) ? – Maximus2012 Jul 25 '13 at 16:27
  • you probably need to create another page that processes the form and sends the email. – Maximus2012 Jul 25 '13 at 16:28
  • For one thing, it's not going to work using `action="mailto:?subject=Hello"`. Haven't you Google'd `"form email php"`? We're here to help with problems you may have with an already running/working script, not to "write a script" all **tailor-made** for you. That's not what SO is about. Try this: https://www.google.ca/search?q=php+email+form&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&channel=np&source=hp&gws_rd=cr – Funk Forty Niner Jul 25 '13 at 16:29
  • **>>** https://www.google.ca/search?q=php+email+form+examples&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&channel=np&source=hp&gws_rd=cr – Funk Forty Niner Jul 25 '13 at 16:35
  • Sorry, and thanks for the tips! – user2617330 Jul 25 '13 at 20:21

2 Answers2

0

action="mailto:?subject=Hello"

This is not what you think it is.

action specifies the destination URL. mailto: links are sent to the client, the server doesn't do anything with them.

Ex:

"mailto:mr.smith@matrix.com"
"http://www.domain.com"

mailto is like http here.


To send mail using PHP you can the mail function or some other implementation. The action in your form will have to point to a script on your server.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
  • Thanks for a quick response. I just showed what I managed to scramble together currently in lieu of my ignorance of PHP. Using the local client and a `mailto`. But, what I want to do, it write something that would handle the email from the server side, sending the same values without a mail client popping up. – user2617330 Jul 25 '13 at 16:41
  • Yes I understood that. You posted no PHP code so I can't comment on that. – Halcyon Jul 25 '13 at 16:42
0
<?php
if(isset($_POST['send'])){

 $_POST['email'];
 $_POST['name'];
 @$_POST['Entry1'];
 @$_POST['Entry2'];
 @$_POST['Entry3'];
@$_POST['Entry4'];

$to      =  $_POST['email'];
$subject = 'the subject';
$message = $_POST['name'] . @$_POST['Entry1'] . @$_POST['Entry2'] .   @$_POST['Entry3']    . @$_POST['Entry4'];
$headers = 'From:you@example.com';

mail($to, $subject, $message, $headers);
echo 'thanks you for your email';
header("where_you_want.php");
}else{
echo 'please try again';
}

?>

<form action="where_you_want.php" method="POST" enctype="text">
<input type="checkbox" name="Entry1" value="URL1">
<input type="checkbox" name="Entry2" value="URL2">
<input type="checkbox" name="Entry3" value="URL3">
<input type="checkbox" name="Entry4" value="URL4">
<label for="name">Name</label><input type="text" id="name" name="name"     placeholder="Your Name">
<label for="email">Email(Required)</label><input type="text" id="email" name="email" placeholder="john_doe@example.com" required class="inputfield">
<input type="submit" name="send" value="">

this is not the best answer but I test it and sending email with value and you can     change value and play around..I hope its help..
samuel
  • 38
  • 1
  • 7