We have an application which sends notification email through exchange server. Right now if exchange is configured for SSL or TLS encryption, we are able to send the mail. If exchange is not configured for any encryption, the application is failing to send mail. The question is
We were using Wireshark and found that it using StartTLS for sending the mail. Below is the code snippet we are using to send mail:
curl_easy_setopt(curl, CURLOPT_URL, "smtp.url.com:25");
curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, "AUTH=NTML PLAIN");
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM_ADDR);
recipients = curl_slist_append(recipients, TO_ADDR);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
Please let me know what are we missing here.
if we add CURLOPT_USE_SSL with CURLUSESSL_NONE as shown below, it works.
if(<condition to mark that mail is using no encryption>)
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_NONE);