0

My php script doesnt send a mail. What's wrong? Do i need headers or other things? Is mail not supported?

Is lorem ipsum a php no mail hack/bug? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent suscipit ante ultricies neque tincidunt ullamcorper. Ut dictum tincidunt scelerisque. Suspendisse vitae quam in neque pellentesque consectetur. Ut ultrices posuere diam, nec interdum leo mattis eget. In hendrerit, nisi a commodo tempor,

My index.php

       <!-- Form -->
    <form action="apply-process.php" method="post" name="apply">
  <div class="row">
    <div class="six columns">
      <label>Your first name</label>
      <input class="u-full-width" type="text" placeholder="John" name="first_name">
    </div>
    <div class="six columns">
      <label>Your last name</label>
      <input class="u-full-width" type="text" placeholder="Doe" name="last_name">
    </div>
  </div>
  <div class="row">
    <div class="six columns">
      <label>Your email</label>
      <input class="u-full-width" type="text" placeholder="john@doe.com" name="email">
    </div>
    <div class="six columns">
      <label>Memberschip</label>
      <select name="memberschip" class="u-full-width" name="membership">
        <option value="Option 1">Normal</option>
        <option value="Option 2">Donator</option>
        <option value="Option 3">eSport member</option>
      </select>
    </div>
  </div>

  <label>Message</label>
  <textarea class="u-full-width" placeholder="Tell us something about yourself and your hobbies. Remember to include your ingame name and Skype name." name="text"></textarea>

  <input class="button-primary" type="submit" value="Submit">
</form>

My process page:

<?php

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$text = $_POST['text'];
$membership = $_POST['membership'];
$to = "administratie@sharp-gaming.nl";
$subject = "New apply from $first_name";

mail ($to, $subject, "From: " . $first_name . $last_name, "Email: " . $email, "Membership: " . $membership, "Message: " . $text);

header('Location: ../index.html');
?>

Thanks, Juul

bummi
  • 27,123
  • 14
  • 62
  • 101
  • You need headers yes. Additionally, make sure that your server is configured to send out email and also make sure that error reporting is turned on for your code. – Maximus2012 May 15 '15 at 21:33
  • Look at some of the examples on this page: http://php.net/manual/en/function.mail.php – Maximus2012 May 15 '15 at 21:34
  • @Maximus2012 Why does the OP **need** headers? Per your link `additional_headers (optional)`. Probably a better idea to have them so it doesn't go to spam but not required. – chris85 May 15 '15 at 22:00
  • 1
    what do you mean by saying "Is lorem ipsum a php no mail hack/bug? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent suscipit ante ultricies neque tincidunt ullamcorper. Ut dictum tincidunt scelerisque. Suspendisse vitae quam in neque pellentesque consectetur. Ut ultrices posuere diam, nec interdum leo mattis eget. In hendrerit, nisi a commodo tempor," ? – Zgr3doo May 15 '15 at 22:08

2 Answers2

0

May be this can help. replace your mail() with lines below:

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: ' .$first_name.$last_name. '<' .$email. '>' . "\r\n";
mail($to,$subject,$text,$headers);
N Kumar
  • 1,302
  • 1
  • 18
  • 25
0

The mail function, http://php.net/manual/en/function.mail.php, takes 4 parameters; to, subject, body, and headers.

mail ($to, 
$subject, 
"From: " . $first_name . $last_name, 
"Email: " . $email, 
"Membership: " . $membership, 
"Message: " . $text);

You are passing it 6 parameters. Headers are not required. I don't know what you are trying to send but your subject, body, and headers are in the wrong places.

Maybe you want...

mail ($to, 
    $subject, 
    "Message: " . $text, 
    "From: $first_name $last_name <$email>");
chris85
  • 23,846
  • 7
  • 34
  • 51
  • Yes, isn't this your original code? Did you try my code above/read it? My code doesn't have 6 parameters going to the `mail` function. – chris85 May 16 '15 at 14:08