Jump to content

PHP Mail.


Ratface

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 protected]";
    $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 protected]";
  $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 protected]";
  $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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.