CURLOPT_MAIL_FROM(3)

πŸ’Œ CURLOPT_MAIL_FROM(3) β€” Library Functions Manual, but make it cute ✨

πŸŽ€ NAME πŸŽ€

CURLOPT_MAIL_FROM β€” SMTP sender address πŸ’Œ

✨ SYNOPSIS ✨

okay bestie, include the header and call it like this:

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MAIL_FROM, char *from);

πŸ¦‹ DESCRIPTION πŸ¦‹

So this is the option where you pass a pointer to a null-terminated string as the parameter. It should be used to specify the sender's email address when sending SMTP mail with libcurl. πŸ’…

An originator email address should be specified with angled brackets (<>) around it β€” and if you don't specify them, they get added automatically. no cap, libcurl handles the glow-up for you ✨

In order to specify DSN parameters (as per RFC 3461), the address has to be written in angled brackets, followed by the parameters. iykyk 🫢

If this parameter is not specified then an empty address is sent to the SMTP server, which might cause the email to be rejected. 😭 literally not the vibe.

The application does not have to keep the string around after setting this option. so you can let it go, 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 πŸ“

blank β€” literally blank, bestie.

🌈 PROTOCOLS 🌈

This functionality affects smtp only.

πŸŽ€ EXAMPLE πŸŽ€

here's the whole vibe in C:

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_FROM, "president@example.com");
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in curl 7.20.0.

πŸ’… 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) for the tea β˜•

πŸ”₯ SEE ALSO πŸ”₯


okay that's the whole page, bestie 🫢 source/version: libcurl, date: 2026-10-12, page: CURLOPT_MAIL_FROM(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from