Browse Source

Add support for custom SMTP ports

The port can be optionally specified by appending `:<port>` to the existing SMTP Server field in settings. If no port is specified, then the default port (25 for insecure or 465 for SSL) is used.

Closes #12212.
PR #17157.
adaptive-webui-19844
Emil M George 3 years ago committed by GitHub
parent
commit
29a964d5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/base/net/smtp.cpp

9
src/base/net/smtp.cpp

@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
#include "base/global.h"
#include "base/logger.h"
#include "base/preferences.h"
#include "base/utils/string.h"
namespace
{
@ -163,16 +164,20 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje @@ -163,16 +164,20 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
}
// Connect to SMTP server
const QStringList serverEndpoint = pref->getMailNotificationSMTP().split(u':');
const QString serverAddress = serverEndpoint[0];
const std::optional<int> serverPort = Utils::String::parseInt(serverEndpoint.value(1));
#ifndef QT_NO_OPENSSL
if (pref->getMailNotificationSMTPSSL())
{
m_socket->connectToHostEncrypted(pref->getMailNotificationSMTP(), DEFAULT_PORT_SSL);
m_socket->connectToHostEncrypted(serverAddress, serverPort.value_or(DEFAULT_PORT_SSL));
m_useSsl = true;
}
else
{
#endif
m_socket->connectToHost(pref->getMailNotificationSMTP(), DEFAULT_PORT);
m_socket->connectToHost(serverAddress, serverPort.value_or(DEFAULT_PORT));
m_useSsl = false;
#ifndef QT_NO_OPENSSL
}

Loading…
Cancel
Save