problem sending email.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have contact us page on my website here the php code for sending the
header("refresh: 5; contact.html");
<meta http-equiv=3D"Content-Type" content=3D"text/html;
charset=3DISO-8859-8" />
<link rel=3D"stylesheet" type=3D"text/css" href=3D"style.css">
<div class=3D"mailform">
if(isset($_POST['Email'])) {

$email_to = "info@mywebsite";

$email_subject = "Contact Form";

$fullname = $_POST['Name'];
$phone = $_POST['Phone'];
$altphone = $_POST['AltPhone'];
$email_from = $_POST['Email'];
$subject = $_POST['Subject'];
$message = $_POST['MoreInfo'];

$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);

$email_message .=3D "Full Name: ".clean_string($fullname)."\n";
$email_message .=3D "Phone: ".clean_string($phone)."\n";
$email_message .=3D "Alternative Phone: ".clean_string($altphone)."\n";
$email_message .=3D "Subject: ".clean_string($subject)."\n";
$email_message .=3D "Message: ".clean_string($message)."\n";

// create email headers
$headers = 'From : '.$email_from."\r\n".
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

<!-- place your own success html below -->



somehow this doesn't work. It doesn't send the emails.

Where is the problem in this code?

Re: problem sending email.

Integrated HR Solutions wrote:
Quoted text here. Click to load it

Probably you need

mail($email, $subject, $message, $headers, "-f ".$return_path );

otherwise return path will be something like '' and the
mail will be junked as it has no valid sender.

Try something simple first like


Re: problem sending email.

On Thu, 29 Sep 2011 06:18:55 -0700 (PDT), Integrated HR Solutions wrote:
Quoted text here. Click to load it
Quoted text here. Click to load it

See that @ at the front of the mail function? That's suppessing some
possible error messages. Take that off. You should be catching errors in
your code, not hiding them.

90. I will not design my Main Control Room so that every workstation is
    facing away from the door.
    --Peter Anspach's list of things to do as an Evil Overlord

Site Timeline