xref: /curl/docs/libcurl/opts/CURLOPT_MAIL_AUTH.md (revision e3fe0200)
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
12---
13
14# NAME
15
16CURLOPT_MAIL_AUTH - SMTP authentication address
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_AUTH, char *auth);
24~~~
25
26# DESCRIPTION
27
28Pass a pointer to a null-terminated string as parameter. This is used to
29specify the authentication address (identity) of a submitted message that is
30being relayed to another server.
31
32This optional parameter allows co-operating agents in a trusted environment to
33communicate the authentication of individual messages and should only be used
34by the application program, using libcurl, if the application is itself a mail
35server acting in such an environment. If the application is operating as such
36and the AUTH address is not known or is invalid, then an empty string should
37be used for this parameter.
38
39Unlike CURLOPT_MAIL_FROM(3) and CURLOPT_MAIL_RCPT(3), the address should not
40be specified within a pair of angled brackets (\<\>). However, if an empty
41string is used then a pair of brackets are sent by libcurl as required by RFC
422554.
43
44The application does not have to keep the string around after setting this
45option.
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    curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
60    curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, "<secret@cave>");
61    res = curl_easy_perform(curl);
62    curl_easy_cleanup(curl);
63  }
64}
65~~~
66
67# AVAILABILITY
68
69Added in 7.25.0
70
71# RETURN VALUE
72
73Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
74CURLE_OUT_OF_MEMORY if there was insufficient heap space.
75