Php mail under subdomains


I use a standard php mail function in one of my forms. The mail function works fine if its a root domain (the form is at: )

I created a subdomain. ( I use the same php mail function but it does not work under the subdomain. ( )

why would that be? possible solutions?


Do you have sm.php in both directories? Without seeing what sm.php does, it’s hard to tell. If it’s not a huge file, post it here and be sure to X out any sensitive information.



Yes, I do have sm.php in both directories.

Here is the sm.php… the good old mail func.

<?php if ($REQUEST_METHOD == "POST") { $txtname = strip_tags($txtname); $txtcompany = strip_tags($txtcompany); $txtemail = strip_tags($txtemail); $txtcomments = strip_tags($txtcomments); $sendto = ""; $subject = "Contact Form"; $message = "Senders Name: " . "$txtname\n" . "Email: " . "$txtemail\n" . "Senders Website: " . "$txtcompany\n\n" . "Message:\n " . "$txtcomments"; mail($sendto, $subject, $message); } ?>


I see that one uses $txtcompany while the other uses $txtwebsite. I hope your sm.php is different for both forms.

Other than that, I don’t see any problems.


I’ll bet it is a register_globals issue. Try this instead:

$txtname = strip_tags($_POST[‘txtname’]);
$txtcompany = strip_tags($_POST[‘txtcompany’]);
$txtemail = strip_tags($_POST[‘txtemail’]);
$txtcomments = strip_tags($_POST[‘txtcomments’]);

$sendto = "";
$subject = “Contact Form”;
$message = “Sender’s Name: $txtname\nEmail: $txtemail\nSender’s Website: $txtcompany\n\nMessage:\n $txtcomments”;

mail($sendto, $subject, $message);
?>[/code]Just as an FYI - you aren’t really doing enough to protect this form script from things like header injection. Also, since you are using double quotes in your $message assignment line, you have no need for all the concatenation (I’ve removed it from my version).

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]

If it’s register_globals, why does it work in one domain, but not in the other (sub)domain?


It depends if you requested the subdomain to be “fully hosted” when you set it up. If you did, then it is a completely separate entity from its parent domain, and can thus have a different PHP setup.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]

That makes sense. There was another thread with a similar issue between a production site and a much later created dev site.