xref: /curl/docs/libcurl/opts/CURLOPT_MAIL_RCPT.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MAIL_RCPT
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_MAIL_AUTH (3)
9  - CURLOPT_MAIL_FROM (3)
10Protocol:
11  - SMTP
12---
13
14# NAME
15
16CURLOPT_MAIL_RCPT - list of SMTP mail recipients
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT,
24                          struct curl_slist *rcpts);
25~~~
26
27# DESCRIPTION
28
29Pass a pointer to a linked list of recipients to pass to the server in your
30SMTP mail request. The linked list should be a fully valid list of
31**struct curl_slist** structs properly filled in. Use curl_slist_append(3) to
32create the list and curl_slist_free_all(3) to clean up an entire list.
33
34When performing a mail transfer, each recipient should be specified within a
35pair of angled brackets (\<\>), however, should you not use an angled bracket
36as the first character libcurl assumes you provided a single email address and
37encloses that address within brackets for you.
38
39When performing an address verification (**VRFY** command), each recipient
40should be specified as the username or username plus domain (as per Section
413.5 of RFC 5321).
42
43When performing a mailing list expand (**EXPN** command), each recipient
44should be specified using the mailing list name, such as `Friends` or
45`London-Office`.
46
47# DEFAULT
48
49NULL
50
51# EXAMPLE
52
53~~~c
54int main(void)
55{
56  CURL *curl = curl_easy_init();
57  if(curl) {
58    CURLcode res;
59    struct curl_slist *list;
60    list = curl_slist_append(NULL, "root@localhost");
61    list = curl_slist_append(list, "person@example.com");
62    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
63    curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, list);
64    res = curl_easy_perform(curl);
65    curl_slist_free_all(list);
66    curl_easy_cleanup(curl);
67  }
68}
69~~~
70
71# AVAILABILITY
72
73Added in 7.20.0. The **VRFY** and **EXPN** logic was added in 7.34.0
74
75# RETURN VALUE
76
77Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
78