cURL: How do I set the email subject when using -F (multipart / attachment)

I'm trying to send an email using cURL. It has to include an attachment, so I'm using the -F / --form option:

(it's a single line, but I wrote here this way for clarificaiton)

curl smtp://smtp.example.com
     --ssl
     --mail-from [email protected]
     --mail-rcpt [email protected]
     --user login
     -F "=<body.txt;encoder=quoted-printable"
     -F "[email protected];encoder=base64"

It kind of works; the mail arrives but I don't know how to set a header on the email itself (in fact, the only one I need by now is the Subject).

I've tried set it to the first part (the text):

     -F "=<body.txt;encoder=quoted-printable;headers=Subject: The files you requested"

But cURL effectively set the header to that part, resulting in an email like this (raw text):

     (email headers not including Subject)

     -----------------part-boundary
     Content-Transfer-Encoding: quoted-printable
     Subject: The files you requested

     (content of body.txt)
     -----------------part-boundary
     Content-Disposition: attachment; filename="files.zip"
     Content-Type: application/octet-stream
     Content-Transfer-Encoding: base64

     (content of files.zip encoded in base64)
     -----------------part-boundary--

So, how do I set the subject of the email?


Although the documentation mentions HTTP only, the -H / --header option works for SMTP also.

So the way to set the email subject is to add this option to the command line:

-H "Subject: The files you requested"

But, as other headers (like To: and CC:) are needed, you may want to write them all to a file and use it:

-H @headers.txt

That's it.