basic php email on website

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
rynophiliac
Forum Newbie
Posts: 3
Joined: Tue Apr 01, 2008 4:40 pm

basic php email on website

Post by rynophiliac »

Hi there i own a small service company in AZ and would like to allow users who visit my website to send me email via php (without using the mailto).

I have read a few tutorials online and have tried a simple version but still cannot get it to work.

I have 2 files in my website directory mail.html and mail.php while i am trying to test and figure this thing out.

mail.html include this coding

<html>
<head><title>Mail sender</title></head>
<body>
<form method="post" action="mail.php">
Email: <input name="email" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
</body>
</html>

and mail.php includes this

<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( "rynophiliac@yahoo.com", "Feedback Form Results",
$message, "From: $email" );
header( "Location: http://www.freshyard.com/thankyou.html" );
?>

but when i go to my mail.html and try to send myself an email it says:

The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.


I have fatcow which supports php so i really dont know what i am doing wrong??
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Re: basic php email on website

Post by deejay »

hi

Think you'll need to ask your hosts.

this code works fine for me.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: basic php email on website

Post by matthijs »

Please, don't use this code on a live server, it's vulnerable to email injection. See
http://www.securephpwiki.com/index.php/Email_Injection
Post Reply