GNURLOPT_MAIL_FROM(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’Œ GNURLOPT_MAIL_FROM(3) β€” like, the curl_easy_setopt options era, bestie πŸ’Œ

okay so real talk, this whole page lives under the curl_easy_setopt options umbrella (that's the manual name, don't @ me), and it's about one very specific little setting. grab a strawberry πŸ“ and let's go.


✨ NAME ✨

CURLOPT_MAIL_FROM β€” the SMTP sender address, aka "who is this email even FROM" πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

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

that's it. that's the whole vibe check. 🫢


🌸 DESCRIPTION 🌸

So you pass a pointer to a null-terminated string as the parameter, bestie. That string is what you use to specify the sender's email address when you're sending SMTP mail with libcurl.

Now here's the iconic detail: an originator email address should be specified with angled brackets (<>) around it β€” and if you don't specify them, they'll just get added automatically for you. the way that libcurl has your back πŸ˜­πŸ‘‘

And a heads up, because this one's a little real: if this parameter is not specified, then an empty address gets sent to the mail server, which may cause the email to be rejected. so like… maybe specify it? πŸ™ˆ

Good news though β€” the application does not have to keep the string around after setting this option. set it and forget it, main character energy. πŸ’…


πŸŽ€ DEFAULT πŸŽ€

blank

(it's giving empty. it's giving nothing. it's giving rejected email potential.) πŸ’€


🧚 PROTOCOLS 🧚

SMTP

that's the one. the only one. periodt. ⭐


πŸ”₯ EXAMPLE πŸ”₯

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "smtp://example.com/");
  curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "president@example.com");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

look at that. clean. correct. lowkey obsessed with it. 🌈


πŸ’œ AVAILABILITY πŸ’œ

Added in 7.20.0 β€” a true elder, highkey iconic for its age. πŸ‘‘


🌟 RETURN VALUE 🌟

  • Returns CURLE_OK if the option is supported βœ…
  • CURLE_UNKNOWN_OPTION if it's not 😬
  • or CURLE_OUT_OF_MEMORY if there was insufficient heap space 😭

pick your fighter, but hopefully it's the first one fr fr.


🫢 SEE ALSO 🫢

go read those too, they're the friend group. πŸ¦‹


and that's the page, bestie! brought to you by libcurl 7.37.0, dated 19 Jun 2014 β€” a vintage moment, truly, and honestly? she ate. πŸ’–βœ¨

πŸ“¦ where this page comes from