Hi all,

Please let me know if there is a way to test for proper SMTP server 
connectivity using libcurl 'without actually sending an email'.
Although this could otherwise be done with a simple telnet EHLO (or HELO), I 
would like to know if it can be accomplished using the libcurl API(s).

My presumption was that, after setting up the SMTP server URL (using 
CURLOPT_URL), attempting just a 'FROM' alone (using CURLOPT_MAIL_FROM) would 
suffice.
However, doing so sort of causes the code to get stalled (and then, eventually 
time out), probably because the library is expecting the 'RCPT' and/or 'DATA' 
values too, in order to round up on the easy_perform.

When  tried with the attached sample code, (with curl v7.23.1), I do observe 
the salutations come from the SMTP server on the other end, which then verifies 
the sender address with a 250 OK,
but just stalls after that.

Appreciate if any of you could throw some light on how I could possibly go 
about it. Thanks in advance.

Regards,
Naveen
#include <stdio.h>
#include <string.h>
#include "curl/curl.h"

#define URL       ("smtp://xx.xx.xx.xx:25")
#define FROM      ("<[email protected]>")

int main(void)
{
    CURL *curl;
    CURLcode result;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if ( curl )
    {
        curl_easy_setopt ( curl, CURLOPT_URL, URL );
        curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1 );
        curl_easy_setopt ( curl, CURLOPT_MAIL_FROM, FROM );

        result = curl_easy_perform ( curl );
        if ( result != CURLE_OK )
        {
            fprintf ( stderr, "curl_easy_perform() failed: %s\n", 
curl_easy_strerror(result) );
        }

        curl_easy_cleanup(curl);
        curl_global_cleanup();

        return 0;
    }
    else
    {
        return -1;
    }
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to