php form mail

Status
Not open for further replies.

stevestephenemery74

New Member
Messages
2
Reaction score
0
Points
0
Complete novice struggling to create site with form mail on it. I have followed all the advice I can find online but am getting nowhere and cannot get a php form to send an email. I have tried putting what is said to be a 'foolproof' mail checking code on the page scripted as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
&lt;?php<br />
mail('*****@gmail.com','Test mail','The mail function is working!');<br />
echo 'Mail sent!';<br />
?&gt;
</body>
</html>

When I load the page through my browser it reports:

<?php
mail('*****@gmail.com','Test mail','The mail function is working!');
echo 'Mail sent!';
?>

But I receive no mail. I have tried directing the mail to my x10 address, but this doesn't work either. I am sure I am missing something obvious (do I have to ativate php mail somewhere?), hoping somebody can help

Many thanks

Steve
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
I hope you take this in the spirit intended, but "complete novice" is a bit of an understatement. Your page is doing exactly what you told it to do, which is to display the text you're seeing.

The tags for PHP have to use real less-than and greater-than signs, not the &lt; and &gt; character entities if you want them to be interpreted by the server. So that part of your page should lokk like this:

PHP:
<?php
mail('*****@gmail.com','Test mail','The mail function is working!');
echo 'Mail sent!';
?>

The character combination <?php turns on the PHP interpreter; the ?> turns it off. The stuff between them is code that will be run by the server before the page is sent to the browser.

By the way, this forum is for support issues -- things that are wrong with your hosting account, not with the code on your site. There is a separate form, Programming Help, for issues like this one. Most of the community doesn't have permission to respond in the support forum, but they can answer questions posted elsewhere, so you're more likely to get help (and sometimes hand-holding) if you post in the appropriate forum.
 
Status
Not open for further replies.
Top