Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Problem Getting Mail Function to Work
June 5, 2008, 4:14 am
rate this thread
I am using a script to try to send an email from a we form. The
script is as follows:
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$phone = $HTTP_POST_VARS['phone'];
$message = $HTTP_POST_VARS['message'];
$name = stripslashes($name);
$email = stripslashes($email);
$phone = stripslashes($phone);
$message = stripslashes($message);
$rec_email = "firstname.lastname@example.org";
$subject = "Web Page Contact Form";
$msg_body .=3D "Name: $name\n";
$msg_body .=3D "Phone Number: $phone\n";
$msg_body .=3D "E-Mail: $email\n";
$msg_body .=3D "Message: $message\n";
$msg_body .=3D "=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
$header_info = "From: ".$name." <".$email.">";
mail($rec_email, $subject, $msg_body, $header_info);
I have confirmed the email account exists, and I can send email to it
outside of the script, but the script does not send the email. Any
idea on what could be the issue? I have used this script on other
websites with out a problem, the only thing I can think of is maye the
domain name is so long, and if that is it, is there anyway around it?
Re: Problem Getting Mail Function to Work
Your script is sloppy and unclear on many point.
$HTTP_POST_VARS is ancient.
Use $_POST superglobal instead.
You use stripslashes. That means you are SURE the slashes are added?
In your php.ini you have magic_quotes_gpc set on, right?
Otherwise you don't want to use stripslashes.
How can you add something to a variable that is not initialized?
$msg_body .= "whatever";
$msg_body = $msg_body."whatever";
and since $msg_body is not set that would give you a warning (or notice,
I am not sure).
Be sure you have errorreporting on (E_ALL) and display errors during
debug here, simply echo all variables you use, eg:
Domainname is not a problem.
Activate errorreporting, and see what you can find.
- » script only loops once, doesn't filter for no files
- — Previous thread in » PHP Scripting Forum