Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

E-mail from server not being sent

the mail() function

Moderators: macek, egami, gesf

E-mail from server not being sent

Postby donpepetucson » Tue Oct 25, 2011 1:45 pm

Hi,
I developed the website http://www.sadddlebrookesoftball.com as an unpaid volunteer for our softball organization in SaddleBrooke, Arizona. The website was originally developed in 2005 using Adobe GoLive CS2. I recently wrote it using Microsoft Expression Web 4.
I have several forms for players and managers to request different items, to sign up for seasons or tournaments or to purchase things. When the user submits the form, the server sends me or the appropriate person the e-mail with the submitted information. I would like to also have the information e-mailed by the server to the person submitting the form. Some of the forms work properly and some do not. I am unable to find the error.
I should mention that I have little experience in PHP and have used examples from the internet to develop the code.
I attempted to upload the two files, Request_Substitute.php and Request_Substitute.html, but could not so I will list the php file here.
----------------------------
<?php
if(isset($_POST["email"])) {

// Specify the managers' email addresses

/*

$email_Adams_Harry = "harrygram4u@gmail.com";
$email_Adams_Rich = "ramsgate45@mas.com";
$email_Bohlman_David = "dgbohlman@yahoo.com";
$email_Corrick_George = "gcorrick@gmail.com";
$email_Fatula_Steve = "spatch68@aol.com";
$email_Gale_Lorne = "lornegale@aol.com";
$email_Hagerty_Rich = "rhtennis@aol.com";
$email_Hamm_Mike = "mhamm@wbhsi.net";
$email_Jarzembinski_Janet = "jgsjarz@yahoo.com";
$email_Lauder_John = "kjlauder@wbhsi.net";
$email_Lestingi_Joe = "pepe.lestingi@gmail.com";
$email_McAlbin_Tom = "tmcalbin@msn.com";
$email_Spevak_Bill = "wgspevak@gmail.com";
$email_Stevens_Dave = "dave1620@aol.com";
$email_Takacs_Jim = "jimtakacs100@gmail.com";
$email_Victor_Ron = "teeman605@aol.com";
$email_Ward_Tim = "tiward1@msn.com";
$email_Weinenger_Harold = "weinenger@yahoo.com";
$email_Wescoe_Bill = "wcwescoe@gmail.com";
$email_West_Greg = "gregwest@aol.com";

*/

// Set up variables

$email_to_SSSA = "joe@saddlebrookesoftball.com";
$recipient_name = "SaddleBrooke Softball Website";
$email_subject = "Request for Substitutes";
$SSSA_Online_Form = "Request for Substitutes";
$link_url = "http://www.sb-ssa.com";
$link_text = "Return to SaddleBrooke Softball Home Page";
$recipient_name = "SaddleBrooke Softball Website";
$recipient = "SSSA";
$date_of_game = $_POST["Date_of_Game"]; // required
$manager = $_POST["Manager"]; // required

$email_from = $_POST["email"]; // required

$league = $_POST["League"]; // required
$team = $_POST["Team"]; // required
$opposing_team = $_POST["Opposing_Team"]; // required
$game_time = $_POST["Game_Time"]; // required
$dugout = $_POST["Dugout"]; // required

// Set the email address for the manager

/*
if($manager == "Lestingi, Joe) $email_from = $email_Lestingi_Joe;
if($manager == "Adams, Harry") $email_from = $email_Adams_Harry;
if($manager == "Adams, Rich") $email_from = $email_Adams_Rich;
if($manager == "Bohlman, David") $email_from = $email_Bohlman_David;
if($manager == "Corrick, George") $email_from = $email_Corrick_George;
if($manager == "Fatula, Steve") $email_from = $email_Fatula_Steve;
if($manager == "Gale, Lorne") $email_from = $email_Gale_Lorne;
if($manager == "Hagerty, Rich") $email_from = $email_Hagerty_Rich;
if($manager == "Hamm, Mike") $email_from = $email_Hamm_Mike;
if($manager == "Jarzembinski, Janet") $email_from = $email_Jarzembinski_Janet;
if($manager == "Lauder, John") $email_from = $email_Lauder_John;
if($manager == "McAlbin, Tom") $email_from = $email_McAlbin_Tom;
if($manager == "Spevak, Bill") $email_from = $email_Spevak_Bill;
if($manager == "Stevens, Dave") $email_from = $email_Stevens_Dave;
if($manager == "Takacs, Jim") $email_from = $email_Takacs_Jim;
if($manager == "Victor, Ron") $email_from = $email_Victor_Ron;
if($manager == "Ward, Tim") $email_from = $email_Ward_Tim;
if($manager == "Weinenger, Harold") $email_from = $email_Weinenger_Harold;
if($manager == "Wescoe, Bill") $email_from = $email_Wescoe_Bill;
if($manager == "West, Greg") $email_from = $email_West_Greg;

*/

// Substitute information

$substitutes_needed = $_POST["Substitutes_Needed"]; // required
$missing_player_1 = $_POST["MissingPlayer1"]; // required
$missing_player_2 = $_POST["MissingPlayer2"];
$missing_player_3 = $_POST["MissingPlayer3"];
$missing_player_4 = $_POST["MissingPlayer4"];
$missing_player_5 = $_POST["MissingPlayer5"];
$missing_player_6 = $_POST["MissingPlayer6"];
$defensive_position_1 = $_POST["Defensive_position_1"];
$defensive_position_2 = $_POST["Defensive_position_2"];
$defensive_position_3 = $_POST["Defensive_position_3"];
$defensive_position_4 = $_POST["Defensive_position_4"];
$defensive_position_5 = $_POST["Defensive_position_5"];
$defensive_position_6 = $_POST["Defensive_position_6"];

// E-mail to SSSA

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$today = date("F j, Y, g:i a");
$email_message = "The following information was submitted on $today\n\n";
$email_message .= "-------------------------------------------------------\n\n";
$email_message .= "Date of Game: " .clean_string($date_of_game). "\n\n";
$email_message .= "Manager: " .clean_string($manager). "\n\n";
$email_message .= "Email: " .clean_string($email_from). "\n\n";
$email_message .= "League: " .clean_string($league). "\n\n";
$email_message .= "Team: " .clean_string($team). "\n\n";
$email_message .= "Opposing Team: " .clean_string($opposing_team). "\n\n";
$email_message .= "Game Time: " .clean_string($game_time). "\n\n";
$email_message .= "Dugout: " .clean_string($dugout). "\n\n";
$email_message .= "Substitutes Needed: " .clean_string($substitutes_needed). "\n\n";
if($missing_player_1 != "") {$email_message .= "Missing Player 1: " .clean_string($missing_player_1). "\n\n";}
if($missing_player_2 != "") {$email_message .= "Missing Player 2: " .clean_string($missing_player_2). "\n\n";}
if($missing_player_3 != "") {$email_message .= "Missing Player 3: " .clean_string($missing_player_3). "\n\n";}
if($missing_player_4 != "") {$email_message .= "Missing Player 4: " .clean_string($missing_player_4). "\n\n";}
if($missing_player_5 != "") {$email_message .= "Missing Player 5: " .clean_string($missing_player_5). "\n\n";}
if($missing_player_6 != "") {$email_message .= "Missing Player 6: " .clean_string($missing_player_6). "\n\n";}
if($defensive_position_1 != "") {$email_message .= "Defensive Position 1: " .clean_string($defensive_position_1). "\n\n";}
if($defensive_position_2 != "") {$email_message .= "Defensive Position 2: " .clean_string($defensive_position_2). "\n\n";}
if($defensive_position_3 != "") {$email_message .= "Defensive Position 3: " .clean_string($defensive_position_3). "\n\n";}
if($defensive_position_4 != "") {$email_message .= "Defensive Position 4: " .clean_string($defensive_position_4). "\n\n";}
if($defensive_position_5 != "") {$email_message .= "Defensive Position 5: " .clean_string($defensive_position_5). "\n\n";}
if($defensive_position_6 != "") {$email_message .= "Defensive Position 6: " .clean_string($defensive_position_6). "\n\n";}

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to_SSSA, $email_subject, $email_message, $headers);

// E-mail to manager

$today = date("F j, Y, g:i a");
$email_message = "The following information was submitted on $today\n\n";
$email_message .= "concerning the $email_subject\n\n";
$email_message .= "-------------------------------------------------------\n\n";
$email_message .= "Date of Game: " .clean_string($date_of_game). "\n\n";
$email_message .= "Manager: " .clean_string($manager). "\n\n";
$email_message .= "Email: " .clean_string($email_from). "\n\n";
$email_message .= "League: " .clean_string($league). "\n\n";
$email_message .= "Team: " .clean_string($team). "\n\n";
$email_message .= "Opposing Team: " .clean_string($opposing_team). "\n\n";
$email_message .= "Game Time: " .clean_string($game_time). "\n\n";
$email_message .= "Dugout: " .clean_string($dugout). "\n\n";
$email_message .= "Substitutes Needed: " .clean_string($substitutes_needed). "\n\n";
if($missing_player_1 != "") {$email_message .= "Missing Player 1: " .clean_string($missing_player_1). "\n\n";}
if($missing_player_2 != "") {$email_message .= "Missing Player 2: " .clean_string($missing_player_2). "\n\n";}
if($missing_player_3 != "") {$email_message .= "Missing Player 3: " .clean_string($missing_player_3). "\n\n";}
if($missing_player_4 != "") {$email_message .= "Missing Player 4: " .clean_string($missing_player_4). "\n\n";}
if($missing_player_5 != "") {$email_message .= "Missing Player 5: " .clean_string($missing_player_5). "\n\n";}
if($missing_player_6 != "") {$email_message .= "Missing Player 6: " .clean_string($missing_player_6). "\n\n";}
if($defensive_position_1 != "") {$email_message .= "Defensive Position 1: " .clean_string($defensive_position_1). "\n\n";}
if($defensive_position_2 != "") {$email_message .= "Defensive Position 2: " .clean_string($defensive_position_2). "\n\n";}
if($defensive_position_3 != "") {$email_message .= "Defensive Position 3: " .clean_string($defensive_position_3). "\n\n";}
if($defensive_position_4 != "") {$email_message .= "Defensive Position 4: " .clean_string($defensive_position_4). "\n\n";}
if($defensive_position_5 != "") {$email_message .= "Defensive Position 5: " .clean_string($defensive_position_5). "\n\n";}
if($defensive_position_6 != "") {$email_message .= "Defensive Position 6: " .clean_string($defensive_position_6). "\n\n";}

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_from, $email_subject, $email_message, $headers);

?>

<font face="verdana" color="#0000ff" size="3"><center><br><br><br><br><br><br>Thank you for visiting the SaddleBrooke Softball Website.<br><br>A copy of the information you submitted
on substitutes is being e-mailed to you.<br><br>Check your Inbox.<br><br><a href="../../../index.html">[ Return to the SaddleBrooke Softball Home Page ]</a></center></font>

<?php
}
?>
----------------------------
I would appreciate your help. Thank you
Joe
donpepetucson
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Oct 25, 2011 1:23 pm

Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.