CURLOPT_MAIL_RCPT.md (2303B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_MAIL_RCPT 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_MAIL_AUTH (3) 9 - CURLOPT_MAIL_FROM (3) 10 Protocol: 11 - SMTP 12 Added-in: 7.20.0 13 --- 14 15 # NAME 16 17 CURLOPT_MAIL_RCPT - list of SMTP mail recipients 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT, 25 struct curl_slist *rcpts); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer to a linked list of recipients to pass to the server in your 31 SMTP mail request. The linked list should be a fully valid list of 32 **struct curl_slist** structs properly filled in. Use curl_slist_append(3) to 33 create the list and curl_slist_free_all(3) to clean up an entire list. 34 35 libcurl does not copy the list, it needs to be kept around until after the 36 transfer has completed. 37 38 When performing a mail transfer, each recipient should be specified within a 39 pair of angled brackets (\<\>), however, should you not use an angled bracket 40 as the first character libcurl assumes you provided a single email address and 41 encloses that address within brackets for you. 42 43 When performing an address verification (**VRFY** command), each recipient 44 should be specified as the username or username plus domain (as per Section 45 3.5 of RFC 5321). 46 47 When performing a mailing list expand (**EXPN** command), each recipient 48 should be specified using the mailing list name, such as `Friends` or 49 `London-Office`. 50 51 Using this option multiple times makes the last set list override the previous 52 ones. Set it to NULL to disable its use again. 53 54 # DEFAULT 55 56 NULL 57 58 # %PROTOCOLS% 59 60 # EXAMPLE 61 62 ~~~c 63 int main(void) 64 { 65 CURL *curl = curl_easy_init(); 66 if(curl) { 67 CURLcode res; 68 struct curl_slist *list; 69 list = curl_slist_append(NULL, "root@localhost"); 70 list = curl_slist_append(list, "person@example.com"); 71 curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/"); 72 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list); 73 res = curl_easy_perform(curl); 74 curl_slist_free_all(list); 75 curl_easy_cleanup(curl); 76 } 77 } 78 ~~~ 79 80 # %AVAILABILITY% 81 82 # RETURN VALUE 83 84 curl_easy_setopt(3) returns a CURLcode indicating success or error. 85 86 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 87 libcurl-errors(3).