Im not getting much help from my host on this one could some one help me please. Here is the PHP script that I use on 5 other host accounts and they all work apart from this host! <?php $subject = 'Enquiry'; $emailadd = 'email here'; $url = 'success.htm'; $req = '1'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "";die;} } $j = strlen($key); if ($j >= 30) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> PHP: It appears to send with no server error shown, however no information is being sent to the email address. I have tried lots of different email accounts and nothing arrives to any of them. Here are some details of the cPanel if this helps... Operating system Linux Kernel version 2.4.21-9.0.3.EL Machine Type i686 Apache version 1.3.34 (Unix) PERL version 5.8.1 Path to PERL /usr/bin/perl Path to sendmail /usr/sbin/sendmail PHP version 4.4.1 MySQL version 4.0.22-standard cPanel Build 10.8.1-RELEASE 113 Theme cPanel X v2.5.0 cPanel Pro 1.0 (RC36) Thanks very much!
Not sure what are you validating in online form. It seems like you are going to send mail when 1.) Form is not empty 2.) Length is not more than 20 chars You can make the code simpler. $subject = $_POST['subject']; $emailadd = $_POST['emailadd']; $text = $_POST['text']; $url = 'success.htm'; foreach($_POST as $key => $value) { if(empty($value)) { echo "$key is empty"; exit(); } if(strlen($value)> 20) { echo "$key is too long"; exit(); } } ///sending email $mail = mail($emailadd, $subject, $text, "From: $emailadd"); if($mail) { echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; } PHP: I did not test it, but it should work
No that did not work either, thanks anyway. So if the PHP script is valid what possible reasons are there it will not send? .htaccess file is empty, is there a line of code I need to put in there? Is there anything the host needs to do there end? Thanks!
Have you check the name of the field in your web form? Make sure they match with the variable defined in the processing script. If nothing wrong with the form, you can try to use <?php mail("fillinyourmail@here", "test", "test", "From: noOne"); ?> Try to see if you can send email without form!
At the end of the script try echoing all the variables to the page, that way you can check they are all being populated correctly. Otherwise you should check you have php mail enabled on your server.
For some reason that script even though valid will not work with this particular host, strange. Anyway I found a free script that works a treat, theres the link if any use to anyone. Thanks for your help.
I know you have resolved your problem, but it appears that your host may have disabled the NOBODY account. By default this is the account that PHP mail() uses to excute the mail command. I know that in the Admin cPanel Tweak settings this can be turned off and on. It is typically recommended by cPanel to turn off the NOBODY account, but it also appears that most of my hosting accounts don't disable this feature.