xref: /curl/docs/libcurl/opts/CURLOPT_MAIL_RCPT.md (revision c4ab3337)
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
12Added-in: 7.20.0
13---
14
15# NAME
16
17CURLOPT_MAIL_RCPT - list of SMTP mail recipients
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_RCPT,
25                          struct curl_slist *rcpts);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a linked list of recipients to pass to the server in your
31SMTP 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
33create the list and curl_slist_free_all(3) to clean up an entire list.
34
35libcurl does not copy the list, it needs to be kept around until after the
36transfer has completed.
37
38When performing a mail transfer, each recipient should be specified within a
39pair of angled brackets (\<\>), however, should you not use an angled bracket
40as the first character libcurl assumes you provided a single email address and
41encloses that address within brackets for you.
42
43When performing an address verification (**VRFY** command), each recipient
44should be specified as the username or username plus domain (as per Section
453.5 of RFC 5321).
46
47When performing a mailing list expand (**EXPN** command), each recipient
48should be specified using the mailing list name, such as `Friends` or
49`London-Office`.
50
51Using this option multiple times makes the last set list override the previous
52ones. Set it to NULL to disable its use again.
53
54# DEFAULT
55
56NULL
57
58# %PROTOCOLS%
59
60# EXAMPLE
61
62~~~c
63int 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
84Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
85