cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [patch] possible SMTP example

From: David Woodhouse <dwmw2_at_infradead.org>
Date: Wed, 15 Dec 2010 10:54:53 +0000

On Wed, 2010-12-15 at 19:16 +1100, Brad Hards wrote:
> /* this becomes the Return-Path header value */
> static const char *from = "bradh_at_exmaple.com";

I suspect you mean 'this is the SMTP reverse-path', not a header at all.
It might be the case that when receiving mail, *your* system puts it
into a Return-Path: header on final delivery; not all do.

> /* this becomes the Envelope-to header value */
> static const char *to = "bradh_at_example.net";

Likewise, this is the envelope recipient. Nothing to do with headers at
all, unless the receiving system happens to put it there.

These are RFC5321 items; not RFC5322. Envelope, not payload.

> curl = curl_easy_init();
> if(curl) {
> /* this is the URL for your mailserver - you can also use an smtps:// URL here */
> curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.net.");
>
> /* Note that this option isn't strictly required, omitting it will result in libcurl
> * will sent the MAIL FROM command with no sender data. That may result in the
> * receiving SMTP system rewriting the header, which will look a bit strange. */
> curl_easy_setopt(curl, CURLOPT_MAIL_FROM, from);

Again, *not* a header. And the empty reverse-path is used deliberately
on many occasions.

It's probably worth mentioning in the comments in the example that
all autoresponses should have an empty reverse-path, and should be
directed to the address in the reverse-path which triggered them.
Otherwise, they could cause an endless loop.
   
> /* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array */
> recipients = curl_slist_append(recipients, to);
> /* You really do have to set this option though - libcurl won't work without it */
> curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);

Well of course it won't. How can you send a mail without anywhere to
send it *to*?

-- 
dwmw2
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-15