PDA

Click to See Complete Forum and Search --> : Mail() Problem


LogicalDohnuts
Dec 20th, 2007, 04:00 PM
Hey guys, I'm making a email script for my company and currently I've got it all rigged up and it should be working, but my email just won't work? What I mean by this is that, even thou I make it use Mail(mysettings etc) the email never comes to me. Could one of you check my script? Thanks.


<?php
// You may edit these to your likings.
$email = "randomfirework@gmail.com"; // Contact email, for visitors
$emailredirectpage = "emailsuccess.php"; // The page they will be re-directed too.
$emailmaxmessage = "500"; // Maximum characters for their message.

// Connected to main form, and grab necessary data.
$emailtitle = $_POST['title'];
$emailmsg = $_POST['message'];

// This is protection against any potential attacks.
$emailtitle = trim($emailtitle);
$emailtitle = preg_replace("/>/","]",$emailtitle);
$emailtitle = preg_replace("/</","[",$emailtitle);

// Finally email the client all the information.
//mail($email,$emailtitle,$emailmsg);

$headers = str_replace(”\r\n”,”\n”,$headers);
@mail ($email, $emailtitle, $emailmsg, $headers);

// End of script.
?>



:thumb:

lintz
Dec 20th, 2007, 04:40 PM
What value is in $headers?

LogicalDohnuts
Dec 20th, 2007, 04:53 PM
What value is in $headers?

Well I've removed that now, messy code I had. I've started using..



// Finally email the client all the information.
if(mail($email_address,$email_title,$email_msg))
{
echo "Succesfully Sent mail!";
//header("Location: $email_redirectpage");
}
else
{
echo "Something's wrong!";
}



And all I get back each time is "Something's wrong!"

I_Love_My_Vans
Dec 20th, 2007, 04:55 PM
Right, make sure your php.ini file has the correct SMTP.

phpinfo() will show you this information