metamuse 05-28-2007, 09:21 PM Hello,
I found a script (http://php.about.com/od/phpapplications/ss/form_mail.htm
) which I've been trying to implement. It's a form script whereby you can choose an email from a dropdown list in the form and the script sends the email to the one you choose.
I copied and pasted the code and set it up in my test area: http://www.pixeldom.co.uk/projects/formtest/form.html
However, when I click the send button I get the following message:
Warning: mail(): SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\hshome\inimod\pixeldom.co.uk\projects\formtest\formtoemail.php on line 27
We encountered an error sending your mail, please notify webmaster@YourCompany.com
Why??!! Although it doesn’t send the enquiry, it sends the ‘Thank you for contacting us’ email so some of it does work.
Please could someone take a look and let me know what I’m doing wrong? I don’t have any knowledge of php!
Thanks in advance...
iLLin 05-28-2007, 09:55 PM Need to see the php code.
metamuse 05-29-2007, 07:25 PM Sorry! Here you go:
<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@YourCompany.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us.
Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.pixeldom.co.uk/projects/formtest/thanks.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>
rafiki 05-29-2007, 07:31 PM couple pointers
1. use the PHP tags [_PHP_]coder here[_/PHP_] with no underscores
2. do not use $_REQUEST
3 die($reason); for the if($name == '') {print "You have not entered a name, please go back and try again";}
4. check to see if both mails sent if ($mail && $mail2) {
code here;
}else{
echo "error";
}
aedrin 05-29-2007, 08:03 PM do not use $_REQUEST
There is no reason not to use request as long as you know what you are doing.
whizard 05-29-2007, 08:38 PM <?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@YourCompany.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us.
Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
elseif{
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.pixeldom.co.uk/projects/formtest/thanks.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }
}
}
?>
After it says, you have not entered an email, please try again, note how I have replaced 'else' with 'elseif'.. Add that and see how it works
HTH
Dan
aedrin 05-29-2007, 08:54 PM Don't fix code for other people. Tell them what needs to be changed so they can understand and learn.
metamuse 05-31-2007, 09:04 PM Hi everyone,
Thanks for your help so far. I tried the 'elseif' and I now get the error 'Parse error: parse error, unexpected T_IF in D:\hshome\inimod\pixeldom.co.uk\projects\formtest\formtoemail2.php on line 25'
What does that mean?
whizard 06-01-2007, 12:43 AM That means I am a retard - you have to either take out the elseif that I told you to put in or give it a condition, but I doubt that's going to fix your main problem.
Sorry
Dan
The error is from this
elseif{
if($name == '') {print "You have not entered a name, please go back and try again";}
// Should be else if(...
|
|