2

Using the command line interface I cannot for the life of me send a text file.

Here's the command line

curl -F "[email protected]" -F "name=Scott" http://www.mydomain.com/go.php

here's the PHP taken from this site but the example was using php for curl not commandline.

<?php
$recipient = "[email protected]";
if (empty($_POST)) {
    // We only accpet POSTs
    header('HTTP/1.0 403 Forbidden');
    exit;
} else {
    // Handle a POST
    $message .= "Submitted at ".date("F j, Y, g:i a")."\n\n";
    $message .= "Name:\n";
    $message .= $_POST['name']."\n\n";
    $message .= "-------------------------------------------\n\n";
    $message .= "Comments:\n\n";
    $message .= $_POST['comments']."\n\n";
    // Send message to email address
    $sent = mail($recipient, "Feedback", 
        $message, "From: Feedback <noreply@some_host.com>\r\n");

    if ($sent) {
?>
        <html>
        <body>
            Got POST and sent email:
            <pre><? echo $message; ?></pre>
        </body>
        </html>
<?php
    } else {
        // Return an error
        header('HTTP/1.0 500 Internal Server Error', true, 500);
        exit;
    }
}
?>

The thing returns correctly and echos the email it sends I don't get the text file contents. That part is blank. Tried a thousand things but no dice.

1
  • can you edit your post to indicate which variables are not working as you expect? $message? Good luck. Commented Nov 17, 2011 at 2:34

1 Answer 1

2

The -F syntax didn't work for me either. But this does:

curl --data-urlencode [email protected] --data-urlencode "name=Scott" http://www.mydomain.com/go.php
Sign up to request clarification or add additional context in comments.

1 Comment

Yes!! Thank you. Works perfectly. Man, spent ages trying to figure it out. Glad you are a genius!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.