Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/31509-php-mail/
Share on other sites

[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?

Regards
Huggie
[/quote]

Hi Huggie

I'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
Link to comment
https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145949
Share on other sites

OK, that's the POST method, in that case try this piece of code...

[code]<?php
foreach ($_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]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-145953
Share on other sites

[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]<?php
foreach ($_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]

Regards
Huggie
[/quote]

Fantastic ... Thanks Huggie.
Link to comment
https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-146037
Share on other sites

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.

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/31509-php-mail/#findComment-146042
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.