-1

Okay, so I've got a VPS with sendmail running as well as php5. The mail server works because I tested somebody elses php contact script and it succesfully sent me an email via a submit button. I can't however seem to get my script to work. Here it is:

<?php

    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message'];
    
    $email_from = $visitor_email;
    $email_subject = "You got work yo!";
    $email_body = $message
    
    
    $to = "myemail@gmail.com";
    $headers = "from: $visitor_email \r\n";
    mail($to,$email_subject,$email_body,$headers);
    
    ?>

Here is the html

<form action="email.php" name="emailform" method="post">

Name:<input type="text" name="name">
<br/>
Email:<input type="text" name="email">
</br>
Message:<input type="text" name="message">

<input type="submit" value="Send Form">
</form>
Thanks for the help
user970638
  • 129
  • 1
  • 2
  • 9
  • 2
    A couple things you can try for debugging: 1) Send a static email. 2) Output some text after the mail function to make sure a fatal error didn't occur. For example, you are missing a semicolon on $email_body = $message in your example code. 3) Run a print_r($_POST); to see what is being posted. – teynon Sep 27 '14 at 01:54
  • why all these unnecessary variables ? what a waste of keystrokes – meda Sep 27 '14 at 02:01
  • Also, some servers get blocked when sending emails to certain email hosts. Have you successfully sent emails with this server before? If not, try to send it to emails on different providers, (yahoo, gmail, etc). However, in my experience gmail is the most accepting. Don't forget to check your spam folder as well. – Evadecaptcha Sep 27 '14 at 02:02
  • @Tom Thanks. it was that semi colon. I scoured that code for hours too. – user970638 Sep 27 '14 at 02:19

1 Answers1

0

You have a syntax error: you are missing a semicolon after $email_body = $message. This is causing your script to fail with a white screen.

Tip for the future: if you had any output in your PHP or checked the logs, you would have caught this.

elixenide
  • 44,308
  • 16
  • 74
  • 100