gnurl_mime_init(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸŽ€ gnurl_mime_init(3) πŸŽ€

okay so bestie, welcome to the libgnurl manual β€” this page is literally about gnurl_mime_init(3), and the vibe check says: mime handle creation. slay. πŸ’…

🌸 NAME 🌸

  • curl_mime_init β€” create a mime handle, bestie. that's the whole NAME-section moment. ✨

✨ SYNOPSIS ✨

       #include <gnurl/curl.h>

       curl_mime * curl_mime_init(CURL * easy_handle);

πŸ’– DESCRIPTION πŸ’–

curl_mime_init(3) creates a handle to a brand-new, empty mime structure. That structure is intended to be used with easy_handle. It starts empty, and then you can fill it in later using the mime API. After that, you attach it to easy_handle using the option CURLOPT_MIMEPOST(3) inside a curl_easy_setopt(3) call. 🫢

Using a mime handle is the recommended way to post an HTTP form, to format and send a multi-part e-mail with SMTP, or to upload such an e-mail to an IMAP server. periodt. πŸ‘‘

πŸ¦‹ AVAILABILITY πŸ¦‹

This is available as long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0 β€” noted, no cap. ⭐

πŸŽ€ RETURN VALUE πŸŽ€

A mime struct handle, or NULL upon failure. that's it, that's the tea. πŸ’…

πŸ”₯ EXAMPLE πŸ”₯

okay bestie, here's the example β€” code is code, so keep it exact:

        CURL *easy = curl_easy_init();
        curl_mime *mime;
        curl_mimepart *part;

        /* Build an HTTP form with a single field named "data", */
        mime = curl_mime_init(easy);
        part = curl_mime_addpart(mime);
        curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
        curl_mime_name(part, "data");

        /* Post and send it. */
        curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
        curl_easy_setopt(easy, CURLOPT_URL, "http://example.com");
        curl_easy_perform(easy);

        /* Clean-up. */
        curl_easy_cleanup(easy);
        curl_mime_free(mime);

πŸ‘‘ SEE ALSO πŸ‘‘

go check out curl_mime_addpart(3), curl_mime_free(3), and CURLOPT_MIMEPOST(3) β€” iykyk. πŸ’–

xoxo, the libgnurl manual β€” source/version libcurl 7.56.0, dated 22 August 2017 πŸ’…

πŸ“¦ where this page comes from