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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Warning: mail() SMTP server response: Need Rcpt command

    I recently moved my website to a new host and I started getting this error when I would try to submit a form:
    Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command.
    The email would send to the recipient, but the receipt would not send to the sender. Error said it was on line 51. I highlighted line 51 in red. Here is a part of the code:

    $my_email = "clientchange@abgemail.com";
    $continue = "/";
    $sender = $_POST['emailedBy'];


    // This line prevents values being entered in a URL

    if ($Filed_By=="")
    {
    /* print("<script language=\"javascript\">window.history.back();</script>");*/
    $noName=1;
    }

    if ($_SERVER['REQUEST_METHOD'] != "POST")
    {
    $noInfo=1;
    exit;
    }


    // This line prevents a blank form being sent

    if ($noName<>1)
    {
    while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

    $message = stripslashes($message);
    $message = "------------------------------" . "\n" .
    "CLIENT CHANGE FORM SUBMISSION" . "\n" .
    " ALLIANCE BENEFIT GROUP - IL " . "\n" .
    "------------------------------" . "\n" .
    $message . "\n" .
    "------------------------------" . "\n";

    $subject = "Client Change Form";
    $headers = "From: " . "clientchange@abgemail.com" . "\n" . "Return-Path: " . "webmaster@abgemail.com" . "\n" . "Reply-To: " . "clientchange@abgemail.com" . "\n";

    mail($my_email,$subject,$message,$headers);
    mail($sender,$subject,$message,$headers);

    $success=1;
    }

    ?>
    Last edited by akknobloch; 06-19-2012 at 08:56 PM.

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    check that $sender = $_POST['emailedBy'] is actually getting set, the error itself means that you don't have a mail recipient ($sender) , check that is not empty.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • Users who have thanked firepages for this post:

    akknobloch (06-20-2012)

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I feel like it is getting set. The user is inputing their email into a text box that has name = "emailedBy". How would I check further into this issue? Thanks for your help!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Don't forget that headers should be separated by \r\n as well. Its possible that its misinterpreting the from header and considering everything as a part of the from.

  • Users who have thanked Fou-Lu for this post:

    akknobloch (06-20-2012)

  • #5
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Fou-Lu - I have the headers seperated by \n. Is that fine or would it solve the issue by seperating them by using \r\n? I have never had an issue before just using \n.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I can't say it will solve the issue. But RFC specifies that headers are separated by \r\n, not by \n which separates content.
    That's the very first thing I'd check. Mail() is somewhat tricky since it has quirks depending on the OS in use.

  • Users who have thanked Fou-Lu for this post:

    akknobloch (06-20-2012)

  • #7
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks. I tried seperating the $headers by \r\n, but the issue is still there. I am not sure why it is not able to pull the $sender email and then send the email. The first mail() option is working, but the second mail() option to the $sender is not.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Is it not pulling the sender out of the post?
    Check and see what the value of $sender is. If its a valid email, this is a host configuration that's blocking it.

  • #9
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Sorry, but how would I find the value of the $sender? Use a debugger to step through the code? Thanks again.

  • #10
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Just echo out the value...

  • #11
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I am currently testing the echo to see what result I get.
    Last edited by akknobloch; 06-20-2012 at 06:00 PM.

  • #12
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    No luck. I tried to echo $sender, but when I submitted the form it did not output an email address. It just gave me the same error that I started with. What could my next step be? Thanks

  • #13
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Do a print_r($_POST);.

    If $sender doesn't have anything, that means your form is screwed up or something screwed up inbetween.

  • #14
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Here is my code. Let me know what you think. Also would it be useful to post the form as well?

    PHP Code:
    <?php

    $my_email 
    "clientchange@abgemail.com";
    $continue "/";
    $sender $_POST['Emailed_By'];


    // This line prevents values being entered in a URL

    if ($Filed_By=="")
    {
     
    /* print("<script language=\"javascript\">window.history.back();</script>");*/
     
    $noName=1;
    }

    if (
    $_SERVER['REQUEST_METHOD'] != "POST")
    {
     
    $noInfo=1;
     exit;
    }


    // This line prevents a blank form being sent

    if ($noName<>1)
    {
     while(list(
    $key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message $message "$key: $value\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

     
    $message stripslashes($message);
     
    $message "------------------------------" "\n" 
                
    "CLIENT CHANGE  FORM SUBMISSION" "\n" .
                
    " ALLIANCE BENEFIT GROUP OF IL " "\n" .
                
    "------------------------------" "\n" .
                
    $message "\n" 
                
    "------------------------------" "\n";

     
    $subject "Client Change Form";
     
    $headers "From: " "clientchange@abgemail.com" "\r\n" "Return-Path: " "webmaster@abgemail.com" "\r\n" "Reply-To: " "clientchange@abgemail.com" "\r\n";

     
    mail($my_email,$subject,$message,$headers);
     
    mail($sender,$subject,$message,$headers);
     
     
    $success=1;
    }

    require_once(
    "header.php")

    ?>

  • #15
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    The problem is most likely on the form side. Like I said, print out the post variables, see if it matches what you think you should get. If not, then you know where your problem is.

  • Users who have thanked Keleth for this post:

    akknobloch (06-20-2012)


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

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