CURLOPT_MAIL_AUTH(3)

πŸ’Œ CURLOPT_MAIL_AUTH(3) πŸ’Œ

okay so bestie, welcome to the Library Functions Manual page for CURLOPT_MAIL_AUTH(3). It's giving SMTP authentication address realness, and we're gonna get through every single deet together. 🫢

✨ NAME ✨

  • CURLOPT_MAIL_AUTH β€” SMTP authentication address

πŸ› οΈ SYNOPSIS πŸ› οΈ

       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_AUTH, char *auth);

πŸ’… DESCRIPTION πŸ’…

okay so you pass a pointer to a null-terminated string as the parameter. This is used to specify the authentication address (identity) of a submitted message that is being relayed to another server. Lowkey important, highkey specific.

This optional parameter allows co-operating agents in a trusted environment to communicate the authentication of individual messages. It should only be used by the application program, using libcurl, if the application is itself a mail server acting in such an environment. If the application is operating as such and the AUTH address is not known or is invalid, then an empty string should be used for this parameter. No cap, that's the rule.

Unlike CURLOPT_MAIL_FROM(3) and CURLOPT_MAIL_RCPT(3), the address should not be specified within a pair of angled brackets (<>). However, if an empty string is used then a pair of brackets are sent by libcurl as required by RFC 2554. So like, the brackets can still show up on the wire even though you're not typing them yourself β€” that's the libcurl glow-up. ✨

The application does not have to keep the string around after setting this option. Literally set it and forget it, bestie.

Using this option multiple times makes the last set string override the previous ones. Set it to NULL to disable its use again. Periodt.

πŸŽ€ DEFAULT πŸŽ€

NULL β€” that's the default, bestie. The void before you set anything. πŸ•³οΈ

🌈 PROTOCOLS 🌈

This functionality affects smtp only. SMTP girlies only, iykyk. πŸ’Œ

πŸ“ EXAMPLE πŸ“

Here's the example, character for character:

       int main(void)
       {
         CURL *curl = curl_easy_init();
         if(curl) {
           CURLcode result;
           curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
           curl_easy_setopt(curl, CURLOPT_MAIL_AUTH, "<secret@cave>");
           result = curl_easy_perform(curl);
           curl_easy_cleanup(curl);
         }
       }

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 7.25.0. Iconic vintage, honestly. πŸŽ€

πŸ’œ RETURN VALUE πŸ’œ

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

πŸ‘‘ SEE ALSO πŸ‘‘

mwah πŸ’‹ β€” this page is from libcurl, dated 2026-10-12, and its footer title is CURLOPT_MAIL_AUTH(3). periodt. 🫢

πŸ“¦ where this page comes from