diff --git a/src/app/application.cpp b/src/app/application.cpp
index 3f42b13e6..e72e5ef09 100644
--- a/src/app/application.cpp
+++ b/src/app/application.cpp
@@ -680,6 +680,24 @@ void Application::sendNotificationEmail(const BitTorrent::Torrent *torrent)
content);
}
+void Application::sendTestEmail() const
+{
+ const Preferences *pref = Preferences::instance();
+ if (pref->isMailNotificationEnabled())
+ {
+ // Prepare mail content
+ const QString content = tr("This is a test email.") + u'\n'
+ + tr("Thank you for using qBittorrent.") + u'\n';
+
+ // Send the notification email
+ auto *smtp = new Net::Smtp();
+ smtp->sendMail(pref->getMailNotificationSender(),
+ pref->getMailNotificationEmail(),
+ tr("Test email"),
+ content);
+ }
+}
+
void Application::torrentAdded(const BitTorrent::Torrent *torrent) const
{
const Preferences *pref = Preferences::instance();
diff --git a/src/app/application.h b/src/app/application.h
index 3218f3d71..ca683fbff 100644
--- a/src/app/application.h
+++ b/src/app/application.h
@@ -127,6 +127,8 @@ public:
int memoryWorkingSetLimit() const override;
void setMemoryWorkingSetLimit(int size) override;
+ void sendTestEmail() const override;
+
#ifdef Q_OS_WIN
MemoryPriority processMemoryPriority() const override;
void setProcessMemoryPriority(MemoryPriority priority) override;
diff --git a/src/base/interfaces/iapplication.h b/src/base/interfaces/iapplication.h
index 211a9ea20..9a34c2fef 100644
--- a/src/base/interfaces/iapplication.h
+++ b/src/base/interfaces/iapplication.h
@@ -83,6 +83,8 @@ public:
virtual int memoryWorkingSetLimit() const = 0;
virtual void setMemoryWorkingSetLimit(int size) = 0;
+ virtual void sendTestEmail() const = 0;
+
#ifdef Q_OS_WIN
virtual MemoryPriority processMemoryPriority() const = 0;
virtual void setProcessMemoryPriority(MemoryPriority priority) = 0;
diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp
index 2f669a1e1..9453d1474 100644
--- a/src/gui/optionsdialog.cpp
+++ b/src/gui/optionsdialog.cpp
@@ -707,6 +707,11 @@ void OptionsDialog::loadDownloadsTabOptions()
connect(m_ui->groupMailNotifAuth, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->mailNotifUsername, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->mailNotifPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
+ connect(m_ui->sendTestEmail, &QPushButton::clicked, this, [this]
+ {
+ app()->sendTestEmail();
+ QMessageBox::information(this, tr("Test email"), tr("Attempted to send email. Check your inbox to confirm success"));
+ });
connect(m_ui->groupBoxRunOnAdded, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->lineEditRunOnAdded, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui
index 5281db9fb..87ea70f39 100644
--- a/src/gui/optionsdialog.ui
+++ b/src/gui/optionsdialog.ui
@@ -1566,6 +1566,19 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Send test email
+
+
+
@@ -3935,6 +3948,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.
groupMailNotifAuth
mailNotifUsername
mailNotifPassword
+ sendTestEmail
checkSmtpSSL
lineEditRunOnAdded
lineEditRunOnFinished
diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp
index 073ada234..21b1f58ae 100644
--- a/src/webui/api/appcontroller.cpp
+++ b/src/webui/api/appcontroller.cpp
@@ -1107,6 +1107,11 @@ void AppController::defaultSavePathAction()
setResult(BitTorrent::Session::instance()->savePath().toString());
}
+void AppController::sendTestEmailAction()
+{
+ app()->sendTestEmail();
+}
+
void AppController::networkInterfaceListAction()
{
QJsonArray ifaceList;
diff --git a/src/webui/api/appcontroller.h b/src/webui/api/appcontroller.h
index 93bf1fd7b..5822b0b48 100644
--- a/src/webui/api/appcontroller.h
+++ b/src/webui/api/appcontroller.h
@@ -48,6 +48,7 @@ private slots:
void preferencesAction();
void setPreferencesAction();
void defaultSavePathAction();
+ void sendTestEmailAction();
void networkInterfaceListAction();
void networkInterfaceAddressListAction();
diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h
index a1887e387..2c01b5b2b 100644
--- a/src/webui/webapplication.h
+++ b/src/webui/webapplication.h
@@ -149,12 +149,12 @@ private:
const QHash, QString> m_allowedMethod =
{
// <, HTTP method>
+ {{u"app"_s, u"sendTestEmail"_s}, Http::METHOD_POST},
{{u"app"_s, u"setPreferences"_s}, Http::METHOD_POST},
{{u"app"_s, u"shutdown"_s}, Http::METHOD_POST},
{{u"auth"_s, u"login"_s}, Http::METHOD_POST},
{{u"auth"_s, u"logout"_s}, Http::METHOD_POST},
{{u"rss"_s, u"addFeed"_s}, Http::METHOD_POST},
- {{u"rss"_s, u"setFeedURL"_s}, Http::METHOD_POST},
{{u"rss"_s, u"addFolder"_s}, Http::METHOD_POST},
{{u"rss"_s, u"markAsRead"_s}, Http::METHOD_POST},
{{u"rss"_s, u"moveItem"_s}, Http::METHOD_POST},
@@ -162,6 +162,7 @@ private:
{{u"rss"_s, u"removeItem"_s}, Http::METHOD_POST},
{{u"rss"_s, u"removeRule"_s}, Http::METHOD_POST},
{{u"rss"_s, u"renameRule"_s}, Http::METHOD_POST},
+ {{u"rss"_s, u"setFeedURL"_s}, Http::METHOD_POST},
{{u"rss"_s, u"setRule"_s}, Http::METHOD_POST},
{{u"search"_s, u"delete"_s}, Http::METHOD_POST},
{{u"search"_s, u"enablePlugin"_s}, Http::METHOD_POST},
diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html
index 624560149..d9bb0a186 100644
--- a/src/webui/www/private/views/preferences.html
+++ b/src/webui/www/private/views/preferences.html
@@ -263,6 +263,9 @@
+
+
+