Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form going to multiple different users not working

    Hello,

    I found a script (http://php.about.com/od/phpapplicati.../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...

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Need to see the php code.

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"; }
    }
    }
    ?>

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    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";
    }

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    do not use $_REQUEST
    There is no reason not to use request as long as you know what you are doing.

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    PHP Code:
    <?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
    Last edited by whizard; 05-29-2007 at 09:42 PM.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #7
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Don't fix code for other people. Tell them what needs to be changed so they can understand and learn.

  • #8
    New to the CF scene
    Join Date
    May 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #9
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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
    Last edited by whizard; 06-01-2007 at 02:01 AM.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #10
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    The error is from this
    PHP Code:
    elseif{
    if(
    $name == '') {print "You have not entered a name, please go back and try again";} 

    // Should be else if(... 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •