I'm very new to php and am having trouble with my send-mail.php file which is being hosted on dreamhost.
// site owner
$to = trim( $_POST['to'] );
$subject = trim( $_POST['subject'] );
// contact form fields
$name = trim( $_POST['name'] );
$email = trim( $_POST['email'] );
$message = trim( $_POST['message'] );
// check for error
$error = false;
if ( $name === "" )
{
$error = true;
}
elseif ( $email === "" )
{
$error = true;
}
elseif ( $message === "" )
{
$error = true;
}
// end check for error
// no error send mail
if ( !$error )
{
$body = "Name: $name
Email: $email
Message: $message";
$headers = 'From: ' . $name . ' <' . $email . '> ' . "
" . 'Reply-To: ' . $email;
mail( $to, $subject, $body, $headers );
echo 'success';
}
else
{
echo 'error';
}
// end no error send mail
?>
So this won't work on DreamHost because of their anti-spam filters.
They said this
The FROM address needs to belong to the domain (ie @mydomain.ie)
Once that is changed in the form settings, mail should be able to send correctly. This change was done to help prevent spam that was coming from the server:
http://dhurl.org/20b
If you would still like to keep the user inputted e-mail address, you would need to set it to be the REPLY-TO address instead of the FROM address.
I'm totally new to php and every time I try to edit the code, with reference to the DreamHost wiki, I end up breaking the thing!
I would really appreciate it if someone could help me out.