tsachu Posted May 12, 2007 Share Posted May 12, 2007 Hi everyone. I'm a newbie. I know pathetically little about php and therefore this is driving me nuts. I'm facing two errors on my website, both of which involves email functions using a php script. The first involves visitors filling out their name and email address, and the server sending this information to my email. The code on the page the visitors are taken to after clicking submit is something like that: <script language="php"> $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "addy@mail.com"; $Subject = "Mailing List"; $Name = Trim(stripslashes($_POST['Name'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=main_pg2.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } </script> However, even though the correct page shows, I NEVER receive the email. I suspect this may lie with my php.ini file.... of which details can be viewed http://www.lifestorydesigns.com/version.php. But of course, due to my pathetic ability to grasp php, I simply cannot figure out what's wrong or lacking. I've a similar problem with my shopping cart order forms. The orders simply doesn't get emailed to me. I previously never had this problem, so I'm suspecting my server changed some settings in the php.ini etc. Anybody could spare the time to enlighten me PLEASE? Thanks a million! Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/ Share on other sites More sharing options...
paul2463 Posted May 12, 2007 Share Posted May 12, 2007 for a start off there is no such thing <script language="php"> if you want to write php it has to be between php tags <?php ?> the page has to be a .php page index.php or some such Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/#findComment-251416 Share on other sites More sharing options...
tsachu Posted May 13, 2007 Author Share Posted May 13, 2007 Ok that has been changed, but it makes no difference. The email still doesn't reach me... Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/#findComment-251839 Share on other sites More sharing options...
ryeman98 Posted May 13, 2007 Share Posted May 13, 2007 What kind of server are you on? Usually, if it's free, they won't let you use the mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/#findComment-251842 Share on other sites More sharing options...
tsachu Posted May 13, 2007 Author Share Posted May 13, 2007 No it's not a free server. I pay for the use of hosting my website on it. It's running on Linux. It has all the while been working fine... then suddenly awhile ago, the emails function stop working. I'm suspecting the server may have changed some settings, because I didn't change anything to my scripts. I did notice while looking through the php.ini settings on http://www.lifestorydesigns.com/version.php that under configuration, the sendmail_from denotes "no value", but the sendmail_path denotes "/usr/sbin/sendmail -t -i". Not sure if this is of any consequence.... Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/#findComment-251847 Share on other sites More sharing options...
tsachu Posted May 13, 2007 Author Share Posted May 13, 2007 Here's the full code after I did the adjustment to the header section <?php $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "enquiries@lifestorydesigns.com"; $Subject = "Mailing List"; $Name = Trim(stripslashes($_POST['Name'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=main_pg2.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Can anyone help pretty please?? I really cannot see what's wrong with it... Quote Link to comment https://forums.phpfreaks.com/topic/51070-help-needed-to-send-email-via-php/#findComment-251994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.