diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-06 20:22:47 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-06 20:22:47 +0100 |
commit | 57445759ee3c26dd03aa8292be3187685a424c1d (patch) | |
tree | 39cce9ee56e030bb9d6d7c23b43953330ad805e2 | |
parent | 9237f0d23fb3700244933b36116397b80f466902 (diff) | |
download | sink-57445759ee3c26dd03aa8292be3187685a424c1d.tar.gz sink-57445759ee3c26dd03aa8292be3187685a424c1d.zip |
Get mailtransport with kolabnow to work
when connecting to smtps:// the command will silently fail,
with wireshark spewing out a cryptic "5.5.2 command not recognized".
The magic commandline (that works) is:
curl smtp://smtp.kolabnow.com:587 -v --mail-from
"$USER" --mail-rcpt "$USER" --ssl -u
$USER.ch:$PW -T alternative.mbox -k --anyauth
-rw-r--r-- | examples/mailtransportresource/mailtransport.cpp | 16 | ||||
-rw-r--r-- | examples/mailtransportresource/mailtransport.h | 4 | ||||
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/examples/mailtransportresource/mailtransport.cpp b/examples/mailtransportresource/mailtransport.cpp index 3d56af9..8e18203 100644 --- a/examples/mailtransportresource/mailtransport.cpp +++ b/examples/mailtransportresource/mailtransport.cpp | |||
@@ -88,7 +88,7 @@ bool sendMessageCurl(const char *to[], int numTos, const char *cc[], int numCcs, | |||
88 | curl_easy_setopt(curl, CURLOPT_URL, server); | 88 | curl_easy_setopt(curl, CURLOPT_URL, server); |
89 | 89 | ||
90 | if (useTls) { | 90 | if (useTls) { |
91 | curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY); | 91 | curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); |
92 | } | 92 | } |
93 | 93 | ||
94 | if (!verifyPeer) { | 94 | if (!verifyPeer) { |
@@ -147,8 +147,6 @@ bool sendMessageCurl(const char *to[], int numTos, const char *cc[], int numCcs, | |||
147 | bool MailTransport::sendMessage(const KMime::Message::Ptr &message, const QByteArray &server, const QByteArray &username, const QByteArray &password, const QByteArray &cacert, MailTransport::Options options) | 147 | bool MailTransport::sendMessage(const KMime::Message::Ptr &message, const QByteArray &server, const QByteArray &username, const QByteArray &password, const QByteArray &cacert, MailTransport::Options options) |
148 | { | 148 | { |
149 | QByteArray msg = message->encodedContent(); | 149 | QByteArray msg = message->encodedContent(); |
150 | SinkLog() << "Sending message " << server << username << password << cacert; | ||
151 | SinkTrace() << "Sending message " << msg; | ||
152 | 150 | ||
153 | QByteArray from(message->from(true)->mailboxes().isEmpty() ? QByteArray() : message->from(true)->mailboxes().first().address()); | 151 | QByteArray from(message->from(true)->mailboxes().isEmpty() ? QByteArray() : message->from(true)->mailboxes().first().address()); |
154 | QList<QByteArray> toList; | 152 | QList<QByteArray> toList; |
@@ -159,8 +157,11 @@ bool MailTransport::sendMessage(const KMime::Message::Ptr &message, const QByteA | |||
159 | for (const auto &mb : message->cc(true)->mailboxes()) { | 157 | for (const auto &mb : message->cc(true)->mailboxes()) { |
160 | ccList << mb.address(); | 158 | ccList << mb.address(); |
161 | } | 159 | } |
162 | bool verifyPeer = options & VerifyPeers; | 160 | const bool verifyPeer = options.testFlag(VerifyPeers); |
163 | bool useTls = options & UseTls; | 161 | const bool useTls = options.testFlag(UseTls); |
162 | |||
163 | SinkLog() << "Sending message " << server << username << password << "CaCert: " << cacert << "Use tls: " << useTls << " Verify peer: " << verifyPeer; | ||
164 | SinkTrace() << "Sending message " << msg; | ||
164 | 165 | ||
165 | const int numTos = toList.size(); | 166 | const int numTos = toList.size(); |
166 | const char* to[numTos]; | 167 | const char* to[numTos]; |
@@ -173,6 +174,9 @@ bool MailTransport::sendMessage(const KMime::Message::Ptr &message, const QByteA | |||
173 | for (int i = 0; i < numCcs; i++) { | 174 | for (int i = 0; i < numCcs; i++) { |
174 | cc[i] = ccList.at(i); | 175 | cc[i] = ccList.at(i); |
175 | } | 176 | } |
177 | //Because curl will fail with smtps, but it won't tell you why. | ||
178 | auto serverAddress = server; | ||
179 | serverAddress.replace("smtps://", "smtp://"); | ||
176 | 180 | ||
177 | return sendMessageCurl(to, numTos, cc, numCcs, msg, useTls, from.isEmpty() ? nullptr : from, username, password, server, verifyPeer, cacert); | 181 | return sendMessageCurl(to, numTos, cc, numCcs, msg, useTls, from.isEmpty() ? nullptr : from, username, password, serverAddress, verifyPeer, cacert); |
178 | } | 182 | } |
diff --git a/examples/mailtransportresource/mailtransport.h b/examples/mailtransportresource/mailtransport.h index 3ef4a6d..662fdc9 100644 --- a/examples/mailtransportresource/mailtransport.h +++ b/examples/mailtransportresource/mailtransport.h | |||
@@ -26,8 +26,8 @@ | |||
26 | namespace MailTransport | 26 | namespace MailTransport |
27 | { | 27 | { |
28 | enum Option { | 28 | enum Option { |
29 | UseTls, | 29 | UseTls = 1, |
30 | VerifyPeers | 30 | VerifyPeers = 2 |
31 | }; | 31 | }; |
32 | Q_DECLARE_FLAGS(Options, Option); | 32 | Q_DECLARE_FLAGS(Options, Option); |
33 | 33 | ||
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 88a90c6..fa7eba4 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -77,7 +77,7 @@ public: | |||
77 | } else { | 77 | } else { |
78 | MailTransport::Options options; | 78 | MailTransport::Options options; |
79 | if (settings.server.contains("smtps")) { | 79 | if (settings.server.contains("smtps")) { |
80 | options &= MailTransport::UseTls; | 80 | options |= MailTransport::UseTls; |
81 | } | 81 | } |
82 | if (!MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8(), options)) { | 82 | if (!MailTransport::sendMessage(msg, settings.server.toUtf8(), settings.username.toUtf8(), settings.password.toUtf8(), settings.cacert.toUtf8(), options)) { |
83 | SinkWarning() << "Failed to send message: " << mail; | 83 | SinkWarning() << "Failed to send message: " << mail; |