CURLOPT_MAIL_RCPT(3)
π CURLOPT_MAIL_RCPT π
okay so this is the CURLOPT_MAIL_RCPT page from the Library Functions Manual, and it's basically the "who are we even sending this email to bestie" option. let's get into it π
β¨ NAME β¨
CURLOPT_MAIL_RCPT β the list of SMTP mail recipients, aka the guest list for your little email party π
β¨ SYNOPSIS β¨
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT,
struct curl_slist *rcpts);
β¨ DESCRIPTION β¨
so you pass in a pointer to a linked list of recipients and that's who gets hit up in your SMTP mail request π¬ the linked list has to be a fully valid list of struct curl_slist structs, properly filled in, no half-baked vibes. use curl_slist_append(3) to build the list and curl_slist_free_all(3) to clean up a whole list when you're done π§Ή
β οΈ important bestie: libcurl does not copy the list. it does not. so you have to keep that list alive and kicking until after the transfer has completed. if you free it early you're gonna have a bad time π
when you're doing a mail transfer, each recipient should be specified inside a pair of angled brackets (<>). however β and this is the cute part β if the first character is not an angled bracket, libcurl just assumes you gave it a single email address and wraps that address in brackets for you π«Ά (she's thoughtful like that)
if you want to specify DSN parameters (as per RFC 3461), the address has to be written in angled brackets, followed by the parameters. no shortcuts there π₯
when you're doing an address verification (that's the VRFY command), each recipient should be specified as the username or username plus domain (as per Section 3.5 of RFC 5321) π¦
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 π
and oop, one thing β using this option multiple times makes the last set list override the previous ones. so it's giving "last one wins" energy. set it to NULL to disable its use again π
β¨ DEFAULT β¨
NULL
β¨ PROTOCOLS β¨
this functionality affects smtp only. just smtp. that's it. that's the whole list π
β¨ EXAMPLE β¨
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
struct curl_slist *list;
list = curl_slist_append(NULL, "root@localhost");
list = curl_slist_append(list, "person@example.com");
list = curl_slist_append(list, "<other@example.com> NOTIFY=SUCCESS");
curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list);
result = curl_easy_perform(curl);
curl_slist_free_all(list);
curl_easy_cleanup(curl);
}
}
look at her go π₯Ή note that the third one uses the angled brackets <> plus DSN parameters, while the first two just get auto-wrapped. iconic behaviour.
β¨ AVAILABILITY β¨
added in curl 7.20.0 β she's been around a minute β
β¨ RETURN VALUE β¨
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK π non-zero means an error occurred β go check libcurl-errors(3) for the tea π
β¨ SEE ALSO β¨
okay that's the whole page, mwah π this one's from libcurl, dated 2026-10-12, and the page name is still CURLOPT_MAIL_RCPT(3) in case you forgot where you were π now go send that mail bestie π¦β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms