xref: /curl/docs/libcurl/opts/CURLOPT_MAIL_AUTH.md (revision c4ab3337)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_MAIL_AUTH
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_MAIL_FROM (3)
9  - CURLOPT_MAIL_RCPT (3)
10Protocol:
11  - SMTP
12Added-in: 7.25.0
13---
14
15# NAME
16
17CURLOPT_MAIL_AUTH - SMTP authentication address
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_AUTH, char *auth);
25~~~
26
27# DESCRIPTION
28
29Pass a pointer to a null-terminated string as parameter. This is used to
30specify the authentication address (identity) of a submitted message that is
31being relayed to another server.
32
33This optional parameter allows co-operating agents in a trusted environment to
34communicate the authentication of individual messages and should only be used
35by the application program, using libcurl, if the application is itself a mail
36server acting in such an environment. If the application is operating as such
37and the AUTH address is not known or is invalid, then an empty string should
38be used for this parameter.
39
40Unlike CURLOPT_MAIL_FROM(3) and CURLOPT_MAIL_RCPT(3), the address should not
41be specified within a pair of angled brackets (\<\>). However, if an empty
42string is used then a pair of brackets are sent by libcurl as required by RFC
432554.
44
45The application does not have to keep the string around after setting this
46option.
47
48Using this option multiple times makes the last set string override the
49previous ones. Set it to NULL to disable its use again.
50
51# DEFAULT
52
53NULL
54
55# %PROTOCOLS%
56
57# EXAMPLE
58
59~~~c
60int main(void)
61{
62  CURL *curl = curl_easy_init();
63  if(curl) {
64    CURLcode res;
65    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
66    curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, "<secret@cave>");
67    res = curl_easy_perform(curl);
68    curl_easy_cleanup(curl);
69  }
70}
71~~~
72
73# %AVAILABILITY%
74
75# RETURN VALUE
76
77Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
78CURLE_OUT_OF_MEMORY if there was insufficient heap space.
79