spikypunker Posted January 10, 2008 Share Posted January 10, 2008 Hi people, first post on here. Relatively new at PHP but have been using php for running mySql and also for a form emailer. I've used this simple script on a few sites: <form action="mail.php" method="post"> Name: <input name="name" type="text" size="40" maxlength="30" /><br /><br /> Email: <input name="email" type="text" size="40" maxlength="50"/><br /><br /> Message<br /><textarea name="message" cols="70" rows="30"></textarea><br /><Br /> <input name="send" type="submit" value="Send" /> </form> PHP: <?php $email = 'chris@mhp.co.uk'; $return = $HTTP_POST_VARS['email']; $subject = $HTTP_POST_VARS['name']; $message = $HTTP_POST_VARS['message']; echo "<h4>Can't send email to $email</h4>"; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif ($subject == "") { echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif (mail($email,$subject,$message, $return)) { echo "<center><h4>Thank you for sending email</h4><br><br><a href='index.html'>Click here to return to site</a></center>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?> But for some reason it's not working at all on a new hosting provider one of my clients has chosen. At first no variables were being passed at all, then i put a .htaccess file on the server with suphp_ConfigPath /mnt/vol1/home/s/t/stanga/ in the file and then a php.ini file on the server too with register_globals = On . This then started allowing the variables to be passed, but the mail form still isn't working. I've had to cut the code down alot just for testing purposes, and it's definately passing the variables but still NOT sending the email!! <?php $email = 'chris@mhp.co.uk'; $return = $HTTP_POST_VARS['email']; $subject = $HTTP_POST_VARS['name']; $message = $HTTP_POST_VARS['main']; $new = $HTTP_POST_VARS['phone']; $another = $HTTP_POST_VARS['method']; $headers .= 'To: Chris <chris@mhp.co.uk> ' . "\r\n"; $headers .= 'From: Website Test <online@test.co.uk>' . "\r\n"; $headers .= 'Cc: chris@mhp.co.uk' . "\r\n"; $headers .= 'Bcc: chris@mhp.co.uk' . "\r\n"; mail($email,$subject,$message, $headers); echo "<a href='index.html'>Click here to go back to site</a>"; ?> Would appreciate help!! peace EDITED BY WILDTEEN88: Please use code tags ( ) when posting code within posts. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/85342-php-version-problems-global-variables/ Share on other sites More sharing options...
jaymc Posted January 10, 2008 Share Posted January 10, 2008 <? mail("email@email.com","yo","testing"); ?> run that, if it doesnt work, 2 possibilities 1:) Web provider as disabled the mail function, which a lot do in whch case you will need to use php for smtp method 2:) There IP has been blacklisted by your email provider. Hotmail? If someone on there server has spammed, that server will be banned, regardless. Try sending it to a gmail account or yahoo, make sure to check junkmail aswell, they nearly always go there if send from a server Quote Link to comment https://forums.phpfreaks.com/topic/85342-php-version-problems-global-variables/#findComment-435462 Share on other sites More sharing options...
wildteen88 Posted January 10, 2008 Share Posted January 10, 2008 ... then i put a .htaccess file on the server with suphp_ConfigPath /mnt/vol1/home/s/t/stanga/ in the file and then a php.ini file on the server too with register_globals = On . This then started allowing the variables to be passed, but the mail form still isn't working. There was no need to enable register_globals as your code does not appear to rely on this setting. However you are using old superglobal variables. Rather than $HTTP_*_VARS you should use $_* eg: $HTTP_POST_VARS should be $_POST $HTTP_GET_VARS should be $_GET $HTTP_SERVER_VARS should be $_SERVER etc. Quote Link to comment https://forums.phpfreaks.com/topic/85342-php-version-problems-global-variables/#findComment-435827 Share on other sites More sharing options...
spikypunker Posted January 11, 2008 Author Share Posted January 11, 2008 Ah wow ok thanks, i'll change them, didn't know that. Yeah thanks for help, I've found out from the server techs and the php is in fact sending the mail but it's being blocked by my mail server. SO problem solved i think! I've gotta new post now....with another problem.... ( Quote Link to comment https://forums.phpfreaks.com/topic/85342-php-version-problems-global-variables/#findComment-436323 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.