mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 14:27:56 +00:00
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.
This commit is contained in:
parent
5e6174c087
commit
29a964d5b7
@ -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
|
||||
}
|
||||
|
||||
// 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…
Reference in New Issue
Block a user