How to send line break with curl?

前端 未结 9 1024
深忆病人
深忆病人 2020-11-27 15:21

I\'ve tried the following to send a line break with curl, but \\n is not interpreted by curl.

curl -X PUT -d \"my message\\n\" http://localhost:         


        
9条回答
  •  借酒劲吻你
    2020-11-27 15:47

    I was using Sendgrid with this code (copied below) originally found here https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html

    \n\n worked in Gmail, but \n was ignored. I tried to double the escape and other suggestions. I also tried \r\n and that did not work in Gmail either. Note: I didn't bother to test other email clients, maybe it was a Gmail-specific problem.

        curl --request POST \
      --url https://api.sendgrid.com/v3/mail/send \
      --header 'Authorization: Bearer YOUR_API_KEY' \
      --header 'Content-Type: application/json' \
      --data '{"personalizations": [{"to": [{"email": "your.email@example.com"}]}],"from": {"email": "example@example.com"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Heya!"}]}'
    

    Eventually I gave up looking for a solution and switched the text/plain to text/html and just used
    tags.

    Someone suggested that Sendgrid converts plaintext to HTML if you have a tracking pixel enabled, which makes sense. Maybe the newlines were destroyed in the plaintext-to-html conversion process. I assume the client wants a tracking pixel, so decided to switch to HTML.

提交回复
热议问题