• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

php / html n00bie question

GeneValgene

Diamond Member
i signed up for moreweb web hosting a while back through AT Hot Deals. i wanted to try creating a form that would contain info, and when submitted, an email would be sent to me.

i looked around and found that there is a mail() function in php. however, i can't seem to get it to work. here's my simple prototype code:

test.htm:
<HTML>
<HEAD>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<form name="f1" action="testsend.php" method="post">
<p align="left">
<input type="submit" name="Submit" value="Submit">
</form>
</BODY>
</HTML>

testsend.php:
<?php

$Name = "Test"; //senders name
$email = "test@gmail.com"; //senders e-mail adress
$recipient = "test@gmail.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command
?>

all i did was copy the two files to my web host. i access the html file, and press the submit button, but i'm not gettin any email 🙁 anyone know if there's anything else i can do to utilize this script?

thanks in advance for helping out a n00b
 
Originally posted by: sourceninja
It all depends if your webhost supports sending email via php or not.

i'm assuming it does...since i have some out of box php programs (e.g. gallery) that seem to work fine and that can send emails.

assuming that my webhost supports sending email via php, is there anythign else i need to do besides uploading those files to my host?
 
Id make a php page that has only the following in it:
<?php
phpinfo();


and see if the path to sendmail is sent. if it is then mail() should work. Otherwise, you will need to use another method.
 
Originally posted by: sourceninja
Id make a php page that has only the following in it:
<?php
phpinfo();


and see if the path to sendmail is sent. if it is then mail() should work. Otherwise, you will need to use another method.

thanks for the tip...i created that php info page, and it does look like the path to sendmail is set...

any other thoughts as to what i might be doing wrong?
 
Try just

print "$recipient, $subject, $mail_body, $header";

and see what it looks like. It might become obvious what's wrong. Also manually construct a static mail() call and see if you can get that to work

mail("me@address.com", "foo", "bar");

Double check that mail isn't actually being sent and just rejected as spam/etc.
 
Originally posted by: Skeeedunt
Try just

print "$recipient, $subject, $mail_body, $header";

and see what it looks like. It might become obvious what's wrong. Also manually construct a static mail() call and see if you can get that to work

mail("me@address.com", "foo", "bar");

Double check that mail isn't actually being sent and just rejected as spam/etc.

thanks a bunch for those tips. ok...i guess it's confirmed that my mail function is not working...i tried the static call of mail("me@address.com", "foo", "bar"); and no email is showing up, not even in the spam folder 🙁

any reasons as to why it might not be working?

-edit-
i've confirmed that the mail function is returning TRUE...yet no emails being sent 🙁

the path to sendmail shows as:

/usr/sbin/sendmail -t -i -f xxxx@xxxx.com
 
Back
Top