tags:

views:

318

answers:

1

I'm writing a php application that submits via curl data to sign up for an iContact email list. However I keep getting an invalid email address error. I think this may be due to the fact that I'm escaping the @ symbol so it looks like %40 instead of @. Also, according to the php documentation for curl_setopt with CURLOPT_POSTFIELDS:

The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path.

So, is there anyway to pass the @ symbol as post data through curl in php without running it through urlencode first?

+2  A: 

Use http_build_query() on your data-array first before passing it to curl_setopt(), that will lead to it sending the form as application/x-www-form-encoded instead of multipart/form-data (and thus the @ is not interpreted).

Also why do you really care about the @ in an email-address? It only matters if the @ is the first character, not somewhere in the middle.

Patrick Daryll Glandien