View Full Version : Help With Email Script

01-21-2008, 06:50 AM
I made a small email script that i cant seem to get to send an email. I was wondering if anyone had the time to look over this code and give me a suggestion.


<form method="POST" action="remove_me.php">
<table border="0" cellspacing="5" cellpadding="5">
<td>Name:</td><td><input type="text" name="name" size="25" /></td>
<td>Badge #:</td><td><input type="text" name="badge" size="25" maxlength="3" /></td>
<td>Class Name:</td><td><input type="text" name="className" size="25" /></td>
<td>Class Date:</td><td><input type="text" name="date" size="25" /></td>
<td>Password:</td><td><input type="password" name="password" size="25" /></td>
<td><input type="submit" name="submit" value="Submit Request" />&nbsp;<input type="reset" name="reset" value="Reset" /></td>


$name = $_POST["name"];
$badge = $_POST["badge"];
$className = $_POST["className"];
$date = $_POST["date"];
$password = $_POST["password"];
$pw = "password";
$to = "rappa819@gmail.com";
$subject = "Class Remove Request";
$message = "$name\n$badge\n$className\n$date";

if (empty($name) || empty($badge) || empty($className) || empty($date) || empty($password)) {
echo "Please Fill In All The Fields. <a href=\"removeme.php\">Back</a>";
else if ($password != $pw) {
echo "Invalid Password. <a href=\"removeme.php\">Back</a>";
else if (!empty($name) && !empty($badge) && !empty($className) && !empty($date) && $password == $pw) {

if (mail($to, $subject, $message)) {
echo "Request Successfully Sent";
else {
echo "Failed to send Removal Request";

At least i get the "Failed to..." echo. But i dont know why its not sending. Im not that great with php as you see.

Thanks in advance.

01-21-2008, 09:59 AM
Quick send mail scripts.



Hope they help you understand what you need done, better.


01-21-2008, 11:37 AM
Put error_reporting ( E_ALL ) at the top of your script and see if you get any warnings or notices.

Are you sure the SMTP is set up in your php.ini?

Jon W
01-21-2008, 06:33 PM
Try putting:

if(isset($_POST['submit'])) {

// then do this...


Hope that helps. Best regrades,

Jon W