• Resolved dipaksaraf

    (@dipaksaraf)


    I am using PHP mail functionality to send mail whenever a user submits the feedback on a post.

    The codes are something like this :
    <?php
    $headers = ‘From: [email protected]’.”\r\n” .
    ‘CC: [email protected]’.”\r\n”.
    ‘Reply-To:$_REQUEST[‘contactemail’]’.”\r\n”;

    if ($_REQUEST[‘contactemail’]){
    mail($to, ‘Response to somedomain.com Ad’, $body.$editlink,$headers);
    mail($_REQUEST[‘contactemail’], ‘Response to somedomain.com Ad’, $client_tag.$body, $headers);
    }else{
    echo'<h2>You seem to have entered an invalid e-mail address. Please try again.’;
    }
    ?>

    When i am using email address in Reply-To: [email protected] it works but when i use $_REQUEST[‘contactemail’] , it gives an error which is as follows: Parse error: syntax error, unexpected T_STRING in runtime.php(42):eval()’d code on line 24.

    LIne 24 is: $headers = ‘From: [email protected]’.”\r\n” .
    ‘CC: [email protected]’.”\r\n”.
    ‘Reply-To:$_REQUEST[‘contactemail’]’.”\r\n”;

    Please suggest how o resolve this issue.

    Thanks
    Dipak

Viewing 2 replies - 1 through 2 (of 2 total)
  • The $_REQUEST information is a PHP variable, but since you have it inside of single-quotes, it’s being treated as a string. Then, the single-quote that wraps contactemail is actually exiting the quoted string, leaving contactemail as plain text outside of a string definition.

    So, PHP thinks you want to send a message to someone with the e-mail address of $_REQUEST[, then it sees contactemail right next to that and doesn’t know what to do with it. Try this code instead:

    'Reply-To:' . $_REQUEST['contactemail'] ."\r\n";
    Thread Starter dipaksaraf

    (@dipaksaraf)

    Hello Curtis

    Thanks for the help, after changing the code as suggested, the mail is working smoothly.

    Thanks for the Help…….

    Dipak

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Mail Problem’ is closed to new replies.