If my other example worked, try this for changing the email address:joshcxa wrote:Actually I have changed my mind. I like webmasters way of doing it.
I've tried to make a page where you type in the recipients email into a text field instead of having to change the email in the code like your example. But i've failed. (noob) Any ideas please?
[php]<?php
if(isset($_POST['submit'])) {
$to = $_POST['email'];
$from = "janedoe@anotherfakedomain.com";
$subject = "This is a test email";
$message = <<<EOF
<html>
<body bgcolor="#ffffff">
<p align="center">
<b>Hello World!</b>
</p>
</body>
</html>
EOF;
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
} else {
?>
<form method="post">
Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Send the mail" />
</form>
<?php
}
?>[/php]






