GNURLOPT_MAIL_RCPT(3)

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

πŸ’Œ GNURLOPT_MAIL_RCPT(3) πŸ’Œ

okay bestie, so this one lives in the curl_easy_setopt options fam (that's the manual name, iykyk) and it's literally all about telling your SMTP server who's getting the mail πŸ’…


✨ NAME ✨

CURLOPT_MAIL_RCPT β€” the list of SMTP mail recipients πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT,
                          struct curl_slist *rcpts);

πŸ’– DESCRIPTION πŸ’–

So you pass a pointer to a linked list of recipients β€” these are the lucky people/things getting your SMTP mail request, no cap. The list has to be a fully valid list of struct curl_slist structs, properly filled in (like, do it right, bestie πŸ™ˆ). Build it with curl_slist_append(3) and then clean up the whole entire list with curl_slist_free_all(3) when you're done β€” leaving it lying around is not the vibe.

When you're doing a mail transfer, each recipient should be specified inside a pair of angled brackets (<>). BUT β€” and this is the cute part β€” if you don't use an angled bracket as the first character, libcurl will assume you handed it a single email address and will enclose that address within brackets for you 🫢 (it's giving "don't worry, I got you").

When you're doing an address verification (that's the VRFY command), each recipient should be specified as the user name, or the user name and domain β€” as per Section 3.5 of RFC5321, periodt πŸ“š.

When you're doing a mailing list expand (the EXPN command), each recipient should be specified using the mailing list name β€” like "Friends" or "London-Office" ⭐.


🌸 DEFAULT 🌸

NULL


🌈 PROTOCOLS 🌈

SMTP


πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  struct curl_slist *list;
  list = curl_slist_append(NULL, "root@localhost");
  list = curl_slist_append(list, "person@example.com");
  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
  curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list);
  ret = curl_easy_perform(curl);
  curl_slist_free_all(list);
  curl_easy_cleanup(curl);
}

like, look at her go πŸ‘‘ two recipients, one URL, one curl_easy_perform, and then responsible cleanup. main character energy fr fr.


🧚 AVAILABILITY 🧚

Added in 7.20.0. The VRFY and EXPN logic was added in 7.34.0 πŸ’œ


πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's it, that's the whole vibe check 😭


⭐ SEE ALSO ⭐


heads up bestie: this page is libcurl 7.37.0, dated 19 Jun 2014 β€” yes she's vintage, and yes she still slays πŸ’…βœ¨πŸ’–
πŸ“¦ where this page comes from