curl / Mailing Lists / curl-library / Single Mail


Re: curl and PGP/GPG

From: Patrick Monnerat <>
Date: Fri, 25 May 2018 17:32:12 +0200

On 05/25/2018 02:53 PM, Alain Reymond wrote:
> Hello,
Hi Alain,
> is there a way to use cURL to send emails encrypted with GPG ?
Yes, providing you handle the encryption yourself and feed curl with the
already encrypted data. There's no data encryption support built in
libcurl and you have to use some external logic/libraries to format and
encrypt your data.
> I would like to send emails to people having a pgp key. The email is
> composed of a text + html body and attached files (pdf or doc).
> A C program receives the different elements (from, to, subject, body
> text, body html, and list of attachments) and uses curl_formadd to
> prepare the mail which is later sent via an html service.
So you don't want to send an SMTP mail ! What you describe is actually
an HTML form submission.
The actual data formatting is thus dependent of what your HTTP server
expects and how it combines the input data to create the RFC822 mail.

As a hint, you can read RFC 3156, as long as the data expected by your
HTTP server can be compatible with this standard.

You can use the mime api rather than the formadd api (which is
deprecated) to fill-in the form fields. See
> My question is : how can I encrypt the email using pgp ?
Maybe have a look at

Received on 2018-05-25