Speculative fix for sending KDM emails via port 465.
authorCarl Hetherington <cth@carlh.net>
Sun, 2 Oct 2016 23:57:56 +0000 (00:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 2 Oct 2016 23:57:56 +0000 (00:57 +0100)
src/lib/emailer.cc

index ceb26caf6ae15e12ea1c42cb93e1d9e358812647..fe6eb529428b32b90a5275c3b472bc8e87f2762a 100644 (file)
@@ -177,7 +177,12 @@ Emailer::send (string server, int port, string user, string password)
                throw NetworkError ("Could not initialise libcurl");
        }
 
-       curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtp://%1:%2", server.c_str(), port).c_str());
+       if (port == 465) {
+               /* "Implicit TLS"; I think curl wants us to use smtps here */
+               curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtps://%1:465", server).c_str());
+       } else {
+               curl_easy_setopt (curl, CURLOPT_URL, String::compose ("smtp://%1:%2", server, port).c_str());
+       }
 
        if (!user.empty ()) {
                curl_easy_setopt (curl, CURLOPT_USERNAME, user.c_str ());