Curl as a Network Protocol Testing Tool

Zhimin Wen
3 min readApr 13
Image by Сергей from Pixabay

Curl is commonly known as its capability dealing with HTTP and HTTPS services. But in fact it has a wide range of protocol that are supported. This make it a perfect tool for testing in some of the restricted environment where other tool could not be easily obtained. The same applies to the container environment.

Let’s explore some of theses protocols curl supports.

Telnet with Curl

Open a telnet session with curl using the common format as protocol://hostname:port

For an example, the HTTP service, type in “GET / HTTP/1.0” and enter twice, then we will have the HTTP response.

curl telnet://
GET / HTTP/1.0

HTTP/1.0 200 OK
Date: Thu, 13 Apr 2023 08:12:59 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-0UjfoqjKKH08-IJyvrc2KA' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri
P3P: CP="This is not a P3P policy! See for more info."
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

With the telnet, we can send email to a SMTP server on the telnet session. But a better approach is to use the built-in protocol support for SMTP.

Send SMTP Email with Curl

Let’s prepare a email text file, named as email.txt, as below,

Subject: Test email

Hi there,
This is just a test emappil.

Now using the following curl command talk to the SMTP server to send the email.

curl -v smtp:// \
--mail-from \
--mail-rcpt \
--upload-file email.txt --user username:password

Some of the verbose output is listed as below,

< 220 ESMTP ready
> EHLO email.txt
< 250 2.1.0 Ok
> RCPT TO:<>
< 250 2.1.0 Ok
< 354 Go ahead
} [114 bytes data]
* We are completely uploaded and fine
< 250 2.0.0…
Zhimin Wen