Jump to content

Sending e-mail via form


Othmo

Recommended Posts

Hello, I just started to learn php, and now I'm trying to create simple e-mail sender. HTML file is here:

 

<html>
<head>
<style>

</style>
</head>
<body>

<form method="post" action="post.php">

Subject:<br /> <input type="text" name="subject" /><br />

E-mail:<br /> <input type="text" name="email" /><br /><br />

Comments:<br />
<textarea cols="30" rows="10" name="message">
</textarea><br />
<input type="submit" value="Send" />
<input type="reset" value="Clear" />


</form>

</body>
</html>

 

and PHP file (post.php) is here

 

<?php

$to = "[email protected]";
$subject = $_POST['subject'];
$email = $_POST['email'];
$message= $_POST['message'];
$headers = "From: $email";

$sent = mail($to, $subject, $email, $message, $headers);

if($sent) {
echo "E-mail was succesfully sent";
}
else {
echo "Problem encountered when sending e-mail";
}

?>

 

That just doesn't seem working, so could ya php gurus tell me if there's something wrong.

Thnx  :D.

Link to comment
https://forums.phpfreaks.com/topic/40260-sending-e-mail-via-form/
Share on other sites

I think...

 

$to = "[email protected]";

 

should be

 

$to = '[email protected]';

 

I might be wrong but that's how my mail form works

 

Those two things are the same..well they work out to be the same anyway, they can be used differently though!

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.