Any Mistake for this code? failed to email .. please help


First name Last name
Your email Your phone
Your message Submit message send message...
<?php $to = ''; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $subject = 'Subject'; $messages = 'From site '.$fname.''.$lname.''.$email.''.$phone.''.$message.''; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From:' . "\r\n"; mail($to, $subject, $messages, $headers); ?>


is From: a valid email address hosted at dreamhost?

Try changing the $to variable also away from gmail. For testing I would use a dreamhost hosted email account. Once it’s working correctly you can try changing things such as the To address to see if it breaks again (it might with a gmail address… or AOL or comcast… all have been problem email domains in the past.)

Assuming that you are not seeing errors during submit, I suspect you’re dealing with a mail block/spam issue.

You might also add something like this right before or after the statement: mail($to, $subject, $messages, $headers);

$fp = fopen($mailcopyfile, “a”);
fputs($fp, $to . $subject . $messages );

which will cause the same info being emailed to be appended to a server file. If this part is working then you know the problem deals with email getting blocked.


forgot to mention to define $mailcopyfile