Get support from Xavier Media
It is currently Sun Dec 08, 2013 12:25 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: PHP Mail problem
PostPosted: Sun Jan 07, 2007 11:47 pm 

Points:
I'm still learning php. my question is this
I have a simple mailform you see below

Code:
<?php
if(($_POST[sender_name] =="") || ($_POST[sender_email] =="") || ($_POST[message] =="")){
   header("Location: simple_form.html");
   exit;
}

$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .="Sender's name: \t$_POST[sender_name]\n";
$msg .="Sender's E-Mail: \t$_POST[sender_email]\n";
$msg .="Message: \t$_POST[message]\n";

$to ="AlfonsoMaldonado@Verizon.net";
$subject ="Web Site Feedback";
$mailheaders ="From: Web Site <cccornerstone.org>";
$mailheaders .="\nReply-To: $_POST[sender_email]\n";

$sentOK = mail($to, $subject, $msg, $mailheaders);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Feedback Form Sent</title>
</head>

<body>
<h1>The following e-mail has been sent:</h1>
<p><strong>Your Name:</strong><br />
<?php echo "$_POST[sender_name]";  ?>
<p><strong>Your E-Mail Address:</strong><br />
<?php echo "$_POST[sender_email]";  ?>
<p><strong>Message:</strong><br />
<?php echo "$_POST[message]";  ?>

</body>
</html>


which receives it's data from the form below

Code:
<form method="post" action="send_simpleform.php">
<p><strong>Your Name:</strong><br />
<input type="text" name="sender_name" size="30" /></p>
<p><strong>Your E-Mail:</strong><br />
<input type="text" name="sender_email" size="30" /></p>
<p><strong>Message:</strong><br />
<textarea name="message" cols="30" rows="5" wrap="virtual"></textarea></p>
<p><input type="submit" name="submit" value="Send This Form" /></p>
</form>


when I load it to my server (gracenet.org) it tells me that my form was sent but I never see it in my mail box? does anyone see a problem with the code above? can PHP send email to .net email address? I'm just wondering why this code doesn't work?

thanks in advance! God Bless!


Report this post
Top
  
Reply with quote  
 Post subject: Re: PHP Mail problem
PostPosted: Mon Jan 08, 2007 12:43 am 

Points:
Try this:

[php]
<?php
if(($_POST['sender_name'] =="") || ($_POST['sender_email'] =="") || ($_POST['message'] =="")){
header("Location: simple_form.html");
exit;
}

$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .="Sender's name: \t$_POST['sender_name']\n";
$msg .="Sender's E-Mail: \t$_POST['sender_email']\n";
$msg .="Message: \t$_POST['message']\n";

$to ="AlfonsoMaldonado@Verizon.net";
$subject ="Web Site Feedback";
$mailheaders ="From: Web Site <cccornerstone.org>";
$mailheaders .="\nReply-To: $_POST['sender_email']\n";

//////////////////////////////////
if ($sentOK = mail($to, $subject, $msg, $mailheaders)) {
// show the below...
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Feedback Form Sent</title>
</head>

<body>
<h1>The following e-mail has been sent:</h1>
<p><strong>Your Name:</strong><br />
<?php echo "$_POST[sender_name]"; ?>
<p><strong>Your E-Mail Address:</strong><br />
<?php echo "$_POST[sender_email]"; ?>
<p><strong>Message:</strong><br />
<?php echo "$_POST[message]"; ?>

</body>
</html>

<?php
} else {
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Feedback Form Sent</title>
</head>
<body>
<h1>EMAILl NOT SENT!</h1>
</body>
</html>
<?php
}
?>[/php]


You forgot the ( ' ) single-quote and with a IF check you can find out what went wrong.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 08, 2007 2:35 am 

Points:
thank you David! but I still have the problem

PHP does execute and I do get the successfully sent page! yet it doesn't show up in my email??? I have it here!

http://cccornerstone.org/Alfonso/emailT ... _form.html

anyway, gracenet say's it supports PHP 4.3.* and from what I can see from the succesfully sent page it does give me the info I sent? yet it doesn't arrive in my email? I have contacted gracenet but I haven't heard anything back from them. Thank You David for your work here!


Report this post
Top
  
Reply with quote  
 Post subject: Mail Script
PostPosted: Mon Jan 08, 2007 4:01 am 

Points:
[php]<?php
if(($_POST['sender_name'] =="") || ($_POST['sender_email'] =="") || ($_POST['message'] =="")){

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Simple Feedback Form</title>
</head>
<body>
<form method="post" action="#">
<p><strong>Your Name:</strong><br>
<input name="sender_name" size="30" type="text"></p>
<p><strong>Your E-Mail:</strong><br>
<input name="sender_email" size="30" type="text"></p>
<p><strong>Message:</strong><br>
<textarea name="message" cols="30" rows="5" wrap="virtual"></textarea></p>
<p><input name="submit" value="Send This Form" type="submit"></p>
</form>
</body></html>

<?php
}else { //Something was posted


$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .="Sender's name: \t". $_POST['sender_name']. "\n";
$msg .="Sender's E-Mail: \t". $_POST['sender_email']. "\n";
$msg .="Message: \t". $_POST['message']. "\n";

$to ="yourname@yoursite.com";
$subject ="Web Site Feedback";
$mailheaders ="From: Web Site <cccornerstone.org>";
$mailheaders .="\nReply-To: ". $_POST['sender_email']. "\n";

//////////////////////////////////
if ($sentOK = mail($to, $subject, $msg, $mailheaders)) {
// show the below...
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Feedback Form Sent</title>
</head>

<body>
<h1>The following e-mail has been sent:</h1>
<p><strong>Your Name:</strong><br />
<?php echo $_POST['sender_name']; ?>
<p><strong>Your E-Mail Address:</strong><br />
<?php echo $_POST['sender_email']; ?>
<p><strong>Message:</strong><br />
<?php echo $_POST['message']; ?>

</body>
</html>

<?php
} else {
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Simple Feedback Form Sent</title>
</head>
<body>
<h1>EMAILl NOT SENT!</h1>
</body>
</html>
<?php
}// END of ELSE NOT SENT
}// END OF ELSE NOT POSTED
?>[/php]

This works on my server. You were putting $_POST's inside of "" marks. That was the problem. :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 08, 2007 4:48 pm 

Points:
Once again. thank you for your help. I like the updated version of the php script that you wrote. anyway here is what I notice

If I set the script up to send to my home address
[php]$to = "whatever@Verizon.net"; // it fails?[/php]

but if i change it to

[php]$to ="mywork@company.com"// it works?[/php]

I tried this on two different servers that support php with the same results? In fact I set up a temp email from hot mail with an underscore in the middle ex. alfonso_maldonado@hotmail.com. and this fails also? this is weird? I have also tried to set it up with webservant@mydomain.org which will forward to my home email yet this also fails? I have sent an email to the webservant address and it does forward just not with the php script! anyway I have sent an email to gracenet.org let me see what they say?

thank You David!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Mon Jan 08, 2007 10:08 pm 

Points:
I've been working with gracenet and they have tested the script does work when sending to them, but fails on a hotmail account! it seems that accounts like verizon.net and hotmail are not accepting emails from PHP scripts. apparently spam bots are using php and other scripts to send their spam and bypass the regular mail service. :-D :shock:

Well I need to figure out another way. thank you!


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]