Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: billi on September 24, 2004, 09:24:38 AM
-
Has anyone sent mail from a PHP page to a remote user?
What is the correct syntax for the PHP.INI file to get mail to be sent?
http://www.php.net/manual/en/function.mail.php is the help site for the mail command.
Here is a sample that might work.
<html>
<head><title>Feedback</title></head>
<body>
<?php
// Handle POST method.
if ($_POST)
{
$name = $_POST['name'];
$email = $_POST['email'];$comments = $_POST['comments'];
// Compose simple text message:
$message = "Message from $name ($email)\n\nComments:\n\n$comments";
// Send message to billir@hotmail.com
mail("billir@hotmail.com", "Feedback", $message);
// Thank the generous user
echo "<h1>Cheers!</h1>\n";
}
else
{
?>
<h1>Feedback</h1>
<form action="<?= $PHP_SELF ?>" method="post">
<p>Name: <input type="text" name="name" /></p>
<p>Email: <input type="text" name="email" /></p>
<p>Comments:</p>
<p><textarea name="comments"></textarea></p>
<p><input type="submit" value="Send!" /></p>
</form>
<?php
}
?>
-
This might be better off posted in a php forum as nothing to do with SME Server :roll:
-
Something along these lines works for me :( set the html form variables )
the php code :
<p><?
$toaddress "somebody@somedom.com";
$subject = "Feedback";
$mailcontent = "Name: ".$_REQUEST["name"]."\n"
."Surname: ".$_REQUEST["surname"]."\n"
."Respond: ".$_REQUEST["respond"]."\n"
."Email: ".$_REQUEST["email"]."\n"
."Cell: ".$_REQUEST["cell"]."\n"
."Tel: ".$_REQUEST["tel"]."\n"
."Subject: ".$_REQUEST["subject"]."\n"
."Name: ".$_REQUEST["message"]."\n";
$fromaddress = $_REQUEST["email"];
mail ($toaddress,$subject,$mailcontent,$fromaddress);?></p>
Rgds
Warren