cURL / Mailing Lists / curl-library / Single Mail

curl-library

SMTP through multi interface

From: Anthony Amundson <aamundson.test_at_gmail.com>
Date: Fri, 28 Mar 2014 09:29:15 -0500

Hello,

I am using the multi functionality within libcurl to send out email
messages to one or more mailservers using SMTP. I am using the following
process for each message:
1) Create an appropriate 'easy' struct
2) curl_multi_add_handle to add the easy handle
3) curl_multi_perfrom and curl_multi_info_read as needed until each SMTP
transaction is complete
4) curl_multi_remove_handle to remove the easy handle after transmission is
complete
5) curl_easy_cleanup to close down the easy handle

The behavior I am observing is that curl_easy_cleanup is not causing SMTP
QUIT commands to be sent for SMTP connections. Instead the multi interface
persists the connections for later use. In some cases this works, and when
sending another email to the same server later the connection is reused.
In other cases I am observing that the email server is timing out our my
connection (presumably due to inactivity).

Is there a way to force the multi interface to send the SMTP QUIT command
once all pending SMTP transactions are complete? Is there some other
mechanism that I should be using here?

I can get the connection to properly close by replacing the line conn->data
= NULL with Curl_disconnect(conn); in multi_connc_remove_handle in
multi.c. Assuming I will just be using the multi interface for sending
SMTP messages, are there significant issues with this change, or a better
way to do this?

Thanks,

Tony

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-03-28