Ratface Posted December 21, 2006 Share Posted December 21, 2006 Hi all,I'm using a 'submit' type button on my site which uses a PHP mail script on my server. It seems to have stopped working and I wondered if any of you guys could shed some light on the issue.The script has been working fine (on many sites, including mine) until I changed hosting company's recently.I've checked with the hosting company that they have PHP Mail enabled (its also got the read / write permissions set-up correctly (644)), and they said that they have. And the script seems to work because I get the 'Email message sent' error message on the site, but the variables are not being sent through via email.The script I'm using is as follows:<? if ($send=="yes") { $to = "email@address.co.uk"; $subject = "$subjectVar"; $body .= "$msgVar"; $from = "$nameVar"; $tfrom = "From: <$emailVar>"; mail($to,$subjectVar,$msgVar,$tfrom); } echo "&errormessage=Email has been sent&";?>I've made no changes, apart from the change of hosting company which leads me to beleive it's them, but as usual they have said they they don't have a problem and it's my script.Can any of you guys (and gals) help at all?Thanks in advance,Simon Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/ Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 This looks like a register globals issue.Are you using the POST or the GET method to submit the form?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145934 Share on other sites More sharing options...
ted_chou12 Posted December 21, 2006 Share Posted December 21, 2006 i have a question, how do you check your host if they have PHP Mail enabled?ThanksTed. Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145941 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 If you create a file that looks like this:[code]<?phpphpinfo();?>[/code]Upload it to your server and run it, you'll be given all the information about the php installation.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145943 Share on other sites More sharing options...
Ratface Posted December 21, 2006 Author Share Posted December 21, 2006 [quote author=ted_chou12 link=topic=119544.msg489699#msg489699 date=1166720298]i have a question, how do you check your host if they have PHP Mail enabled?ThanksTed.[/quote]I asked them Ted ... Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145944 Share on other sites More sharing options...
Ratface Posted December 21, 2006 Author Share Posted December 21, 2006 [quote author=HuggieBear link=topic=119544.msg489692#msg489692 date=1166719901]This looks like a register globals issue.Are you using the POST or the GET method to submit the form?RegardsHuggie[/quote]Hi HuggieI'm actually using Flash with the below script attached to a button:on (release) { if ((nameVar=="")||(emailVar=="")||(subjectVar=="")||(msgVar=="")) { errormessage="Please fill all the fields"; } else { errormessage="Sending...."; send="yes"; this.loadVariables("contact.php",'POST'); send="no"; nameVar=""; emailVar=""; subjectVar=""; msgVar=""; }}As I say, this has worked fine for nearly a year now without any changes.Thanks guys,Simon Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145949 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 OK, that's the POST method, in that case try this piece of code...[code]<?phpforeach ($_POST as $k => $v){ $$k = $v;}if ($send=="yes") { $to = "email@address.co.uk"; $subject = "$subjectVar"; $body .= "$msgVar"; $from = "$nameVar"; $tfrom = "From: <$emailVar>"; mail($to,$subjectVar,$msgVar,$tfrom);}echo "&errormessage=Email has been sent&";?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145953 Share on other sites More sharing options...
ted_chou12 Posted December 21, 2006 Share Posted December 21, 2006 This is all of its information, but i dont know which one to look for:Thanks,Edited, this is private, and too long.... Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145959 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 It looks as though the mail extension is all installed and pointing to the right place on that server.Try not to post large blocks of text like that, it's not very pleasing on the eye ;)RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145962 Share on other sites More sharing options...
Ratface Posted December 21, 2006 Author Share Posted December 21, 2006 [quote author=HuggieBear link=topic=119544.msg489712#msg489712 date=1166720934]OK, that's the POST method, in that case try this piece of code...[code]<?phpforeach ($_POST as $k => $v){ $$k = $v;}if ($send=="yes") { $to = "email@address.co.uk"; $subject = "$subjectVar"; $body .= "$msgVar"; $from = "$nameVar"; $tfrom = "From: <$emailVar>"; mail($to,$subjectVar,$msgVar,$tfrom);}echo "&errormessage=Email has been sent&";?>[/code]RegardsHuggie[/quote]Fantastic ... Thanks Huggie. Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-146037 Share on other sites More sharing options...
HuggieBear Posted December 21, 2006 Share Posted December 21, 2006 OK, if that worked it's because your old server had register_globals switched on, and the new one has it switched off.This will affect any php code you've moved that uses the old register globals feature.Don't forget to mark the topic as solved by using the 'Solved' button at the bottom of the page.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-146042 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.