diff --git a/lib/AppInfo/BootstrapSingleton.php b/lib/AppInfo/BootstrapSingleton.php
index 3275aa2beae533de3deb07d792e40fb32d96d650..3d838e2c876e0753ce268e040a36abb6f19cba62 100644
--- a/lib/AppInfo/BootstrapSingleton.php
+++ b/lib/AppInfo/BootstrapSingleton.php
@@ -54,8 +54,6 @@ use OCA\Mail\Service\MailTransmission;
 use OCA\Mail\Service\UserPreferenceSevice;
 use OCP\AppFramework\IAppContainer;
 use OCP\EventDispatcher\IEventDispatcher;
-use OCP\IUser;
-use OCP\IUserManager;
 use OCP\Util;
 
 class BootstrapSingleton {
diff --git a/lib/Command/DiagnoseAccount.php b/lib/Command/DiagnoseAccount.php
index 31b1c3d2438f8910c504b9378ece66909de4fc13..18e5ed29d24a1462b3d55eb04be0a26e92009b96 100644
--- a/lib/Command/DiagnoseAccount.php
+++ b/lib/Command/DiagnoseAccount.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
 namespace OCA\Mail\Command;
 
 use Horde_Imap_Client;
-use Horde_Imap_Client_Data_Capability;
 use Horde_Imap_Client_Exception;
 use Horde_Imap_Client_Mailbox;
 use Horde_Imap_Client_Socket;
diff --git a/lib/Contracts/IMailManager.php b/lib/Contracts/IMailManager.php
index fbca090e5b805c4ecc644c259a1944b6af69cf69..7d372d6868bf3c13c90cf1f781d5faf11c5cba5b 100644
--- a/lib/Contracts/IMailManager.php
+++ b/lib/Contracts/IMailManager.php
@@ -28,8 +28,6 @@ use OCA\Mail\Exception\ClientException;
 use OCA\Mail\Exception\ServiceException;
 use OCA\Mail\Folder;
 use OCA\Mail\IMAP\FolderStats;
-use OCA\Mail\IMAP\Sync\Request as SyncRequest;
-use OCA\Mail\IMAP\Sync\Response as SyncResponse;
 use OCA\Mail\Model\IMAPMessage;
 
 interface IMailManager {
diff --git a/lib/Db/Mailbox.php b/lib/Db/Mailbox.php
index c479f54101be87766949ad126410e0c4980671e4..544f8d599b93b8c32a7f445bbc8593367ae99b5a 100644
--- a/lib/Db/Mailbox.php
+++ b/lib/Db/Mailbox.php
@@ -23,13 +23,11 @@
 
 namespace OCA\Mail\Db;
 
-use Horde_Imap_Client;
 use OCA\Mail\Folder;
 use OCP\AppFramework\Db\Entity;
 use function in_array;
 use function json_decode;
 use function ltrim;
-use function rtrim;
 use function strtolower;
 
 /**
diff --git a/lib/Db/MailboxMapper.php b/lib/Db/MailboxMapper.php
index 6fcb527c5c1f0c8a431e6959317667dfdf5bb2fd..29f302ffccdba41c3084cc5375beab3da68b0236 100644
--- a/lib/Db/MailboxMapper.php
+++ b/lib/Db/MailboxMapper.php
@@ -32,7 +32,6 @@ use OCP\AppFramework\Db\QBMapper;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
-use OCP\Security\ISecureRandom;
 
 class MailboxMapper extends QBMapper {
 
diff --git a/lib/Http/Middleware/ProvisioningMiddleware.php b/lib/Http/Middleware/ProvisioningMiddleware.php
index b99d2eb3d76498c367f124a400e13f5b064dc280..bcbb180fa88c46f148fa1d38cfc6df3a490e5cb1 100644
--- a/lib/Http/Middleware/ProvisioningMiddleware.php
+++ b/lib/Http/Middleware/ProvisioningMiddleware.php
@@ -30,7 +30,6 @@ use OCA\Mail\Service\Provisioning\Manager as ProvisioningManager;
 use OCP\AppFramework\Middleware;
 use OCP\Authentication\Exceptions\CredentialsUnavailableException;
 use OCP\Authentication\Exceptions\PasswordUnavailableException;
-use OCP\Authentication\LoginCredentials\ICredentials;
 use OCP\Authentication\LoginCredentials\IStore as ICredentialStore;
 use OCP\ILogger;
 use OCP\IUserSession;
diff --git a/lib/Http/ProxyDownloadResponse.php b/lib/Http/ProxyDownloadResponse.php
index 3fa4d3275bd0d87f067851ea2ff98f75989fa29c..72929b8c33d306686be9a1e404cecba50b0d26f1 100644
--- a/lib/Http/ProxyDownloadResponse.php
+++ b/lib/Http/ProxyDownloadResponse.php
@@ -25,9 +25,7 @@ declare(strict_types=1);
 namespace OCA\Mail\Http;
 
 use DateTime;
-use OC;
 use OCP\AppFramework\Http\DownloadResponse;
-use OCP\AppFramework\Utility\ITimeFactory;
 
 class ProxyDownloadResponse extends DownloadResponse {
 
diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php
index c96b4453e8794a37100dc564d1763f9ff2b7f79a..ee188032479c95c31f8a2d00a6808e0896038872 100644
--- a/lib/IMAP/MessageMapper.php
+++ b/lib/IMAP/MessageMapper.php
@@ -27,7 +27,6 @@ use Horde_Imap_Client;
 use Horde_Imap_Client_Base;
 use Horde_Imap_Client_Data_Fetch;
 use Horde_Imap_Client_Exception;
-use Horde_Imap_Client_Exception_NoSupportExtension;
 use Horde_Imap_Client_Fetch_Query;
 use Horde_Imap_Client_Ids;
 use Horde_Imap_Client_Socket;
diff --git a/lib/Mailbox.php b/lib/Mailbox.php
index c357bdfe989ca4b0a3835facc66806c3105f5c3b..09143f70fa0256720e13a60ac3b2ee0c54eeefe6 100644
--- a/lib/Mailbox.php
+++ b/lib/Mailbox.php
@@ -31,13 +31,10 @@
 
 namespace OCA\Mail;
 
-use DateTime;
 use Horde_Imap_Client;
 use Horde_Imap_Client_Exception;
-use Horde_Imap_Client_Fetch_Query;
 use Horde_Imap_Client_Ids;
 use Horde_Imap_Client_Mailbox;
-use Horde_Imap_Client_Search_Query;
 use Horde_Imap_Client_Socket;
 use OCA\Mail\Model\IMAPMessage;
 use OCA\Mail\Service\IMailBox;
diff --git a/lib/Migration/Version0156Date20190828140357.php b/lib/Migration/Version0156Date20190828140357.php
index cf4cd72f233f9f4416202ff6096f9cae97886fe5..42268400ae5585416fe1bef20554f35cad6fee1f 100644
--- a/lib/Migration/Version0156Date20190828140357.php
+++ b/lib/Migration/Version0156Date20190828140357.php
@@ -24,7 +24,6 @@ namespace OCA\Mail\Migration;
 
 use Closure;
 use OCP\DB\ISchemaWrapper;
-use OCP\Migration\IMigrationStep;
 use OCP\Migration\SimpleMigrationStep;
 use OCP\Migration\IOutput;
 
diff --git a/lib/Migration/Version0161Date20190902114635.php b/lib/Migration/Version0161Date20190902114635.php
index 507a35dac9f320d1bd24fe767e0e6f995dff4be9..d3e9e718a5e1171923ffd3e1426d65b51a29e843 100644
--- a/lib/Migration/Version0161Date20190902114635.php
+++ b/lib/Migration/Version0161Date20190902114635.php
@@ -25,7 +25,6 @@ namespace OCA\Mail\Migration;
 
 use Closure;
 use OCP\DB\ISchemaWrapper;
-use OCP\DB\QueryBuilder\IQueryBuilder;
 use OCP\IDBConnection;
 use OCP\Migration\SimpleMigrationStep;
 use OCP\Migration\IOutput;
diff --git a/lib/Migration/Version0190Date20191118160843.php b/lib/Migration/Version0190Date20191118160843.php
index e66d42d3d9aa9891723944ad9d0f0714198e2e89..5ea0f4548c85ffc30cb54114361617f9247b0c08 100644
--- a/lib/Migration/Version0190Date20191118160843.php
+++ b/lib/Migration/Version0190Date20191118160843.php
@@ -27,7 +27,6 @@ namespace OCA\Mail\Migration;
 
 use Closure;
 use OCP\DB\ISchemaWrapper;
-use OCP\IDBConnection;
 use OCP\Migration\SimpleMigrationStep;
 use OCP\Migration\IOutput;
 
diff --git a/lib/Migration/Version1030Date20200228105714.php b/lib/Migration/Version1030Date20200228105714.php
index 0b68533d9e785b4180540ad9668107f6632b5cc2..c2765626e0e91f1f3c4d6ccefa93041019e36de1 100644
--- a/lib/Migration/Version1030Date20200228105714.php
+++ b/lib/Migration/Version1030Date20200228105714.php
@@ -4,7 +4,6 @@ declare(strict_types=1);
 
 namespace OCA\Mail\Migration;
 
-use Closure;
 use OCP\IDBConnection;
 use OCP\Migration\IOutput;
 use OCP\Migration\SimpleMigrationStep;
diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php
index 1e847f1e6500038a765ea9279dc3e4bc1a61367b..180ea30d599f31b9918431968a8887582bd480ae 100644
--- a/lib/Model/IMAPMessage.php
+++ b/lib/Model/IMAPMessage.php
@@ -48,7 +48,6 @@ use OCP\AppFramework\Db\DoesNotExistException;
 use OCP\Files\File;
 use OCP\Files\SimpleFS\ISimpleFile;
 use function base64_encode;
-use function json_encode;
 use function mb_convert_encoding;
 
 class IMAPMessage implements IMessage, JsonSerializable {
diff --git a/lib/Model/IMessage.php b/lib/Model/IMessage.php
index 2f9385ee9023f018298f9e21f4fe4a675133e69e..52935f11604f7f9a3d286f325fc1ab75eae064c4 100644
--- a/lib/Model/IMessage.php
+++ b/lib/Model/IMessage.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OCA\Mail\Model;
 
-use Horde_Mail_Rfc822_List;
 use OCA\Mail\AddressList;
 use OCA\Mail\Db\LocalAttachment;
 use OCP\Files\File;
diff --git a/lib/Model/Message.php b/lib/Model/Message.php
index 3dae4b736fd1fcdd6cb870b0840e25788ac0b421..716127873fb88f6bf640bda806e758517798af47 100644
--- a/lib/Model/Message.php
+++ b/lib/Model/Message.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OCA\Mail\Model;
 
-use Horde_Mail_Rfc822_List;
 use Horde_Mime_Part;
 use OCA\Mail\AddressList;
 use OCA\Mail\Db\LocalAttachment;
diff --git a/lib/Model/NewMessageData.php b/lib/Model/NewMessageData.php
index 9f37f5e3632da186266b690784d27cac0d629823..f802b20339fa031d32ca543bf1b3d1dc14127fa9 100644
--- a/lib/Model/NewMessageData.php
+++ b/lib/Model/NewMessageData.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OCA\Mail\Model;
 
-use Horde_Mail_Rfc822_List;
 use OCA\Mail\Account;
 use OCA\Mail\AddressList;
 
diff --git a/lib/SMTP/SmtpClientFactory.php b/lib/SMTP/SmtpClientFactory.php
index 169f713c36b7c91d6b8bdfaa5daf085a11e6df7b..40d69f6a6641f82a49be3ba1705128501ad9bedc 100644
--- a/lib/SMTP/SmtpClientFactory.php
+++ b/lib/SMTP/SmtpClientFactory.php
@@ -33,7 +33,6 @@ use OCA\Mail\Account;
 use OCA\Mail\Support\HostNameFactory;
 use OCP\IConfig;
 use OCP\Security\ICrypto;
-use OCP\Util;
 
 class SmtpClientFactory {
 
diff --git a/lib/Service/Attachment/AttachmentService.php b/lib/Service/Attachment/AttachmentService.php
index fdc6660c4bfc02b6008107076de673730b3f8e89..d9fe9c69371d5e9855f7250778749cb95939d1fe 100644
--- a/lib/Service/Attachment/AttachmentService.php
+++ b/lib/Service/Attachment/AttachmentService.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
 
 namespace OCA\Mail\Service\Attachment;
 
-use Exception;
 use OCA\Mail\Contracts\IAttachmentService;
 use OCA\Mail\Db\LocalAttachment;
 use OCA\Mail\Db\LocalAttachmentMapper;
diff --git a/lib/Service/HtmlPurify/TransformCSSBackground.php b/lib/Service/HtmlPurify/TransformCSSBackground.php
index 7b72fcf654178759bc30b68156ac5e7f95874643..723f50f5e41721ef67757a5d42fbab8d8b982fa5 100755
--- a/lib/Service/HtmlPurify/TransformCSSBackground.php
+++ b/lib/Service/HtmlPurify/TransformCSSBackground.php
@@ -29,7 +29,6 @@ use HTMLPurifier_AttrTransform;
 use HTMLPurifier_Config;
 use HTMLPurifier_Context;
 use OCP\IURLGenerator;
-use OCP\Util;
 
 /**
  * Adds copies src to data-src on all img tags.
diff --git a/lib/Service/IMailBox.php b/lib/Service/IMailBox.php
index 012a78958e672b2d39eb6050f25d4851aa8ce976..177e33d229e0a2886c6e21614cabbb5fe7048886 100644
--- a/lib/Service/IMailBox.php
+++ b/lib/Service/IMailBox.php
@@ -25,7 +25,6 @@ declare(strict_types=1);
 namespace OCA\Mail\Service;
 
 use Horde_Imap_Client;
-use Horde_Imap_Client_Search_Query;
 use OCA\Mail\Attachment;
 use OCA\Mail\Model\IMessage;
 
diff --git a/lib/Service/Provisioning/Manager.php b/lib/Service/Provisioning/Manager.php
index bdc5091627eeaeed71346d3611d6c13b8721d91b..d0088dbbf52508549926cf5018f222a221138966 100644
--- a/lib/Service/Provisioning/Manager.php
+++ b/lib/Service/Provisioning/Manager.php
@@ -26,8 +26,6 @@ namespace OCA\Mail\Service\Provisioning;
 use OCA\Mail\Db\MailAccount;
 use OCA\Mail\Db\MailAccountMapper;
 use OCP\AppFramework\Db\DoesNotExistException;
-use OCP\AppFramework\Db\MultipleObjectsReturnedException;
-use OCP\IDBConnection;
 use OCP\ILogger;
 use OCP\IUser;
 use OCP\IUserManager;
diff --git a/lib/Service/Sync/SyncService.php b/lib/Service/Sync/SyncService.php
index 35c5f5dc3783280b4095de30aa6020a5fb283a39..cfc121e3acfd563635a0bc81563744618e2669db 100644
--- a/lib/Service/Sync/SyncService.php
+++ b/lib/Service/Sync/SyncService.php
@@ -31,7 +31,6 @@ use OCA\Mail\Db\MailboxMapper;
 use OCA\Mail\Db\Message;
 use OCA\Mail\Db\MessageMapper;
 use OCA\Mail\Exception\ClientException;
-use OCA\Mail\Exception\IncompleteSyncException;
 use OCA\Mail\Exception\MailboxNotCachedException;
 use OCA\Mail\Exception\ServiceException;
 use OCA\Mail\IMAP\PreviewEnhancer;
diff --git a/lib/Service/UserPreferenceSevice.php b/lib/Service/UserPreferenceSevice.php
index 43614361c1320d2062e5c05b630875554a0d2da1..330ca42f84c41c7f9ad748e1c507c069563e5731 100644
--- a/lib/Service/UserPreferenceSevice.php
+++ b/lib/Service/UserPreferenceSevice.php
@@ -24,7 +24,6 @@
 
 namespace OCA\Mail\Service;
 
-use function is_bool;
 use OCA\Mail\Contracts\IUserPreferences;
 use OCP\IConfig;
 
diff --git a/tests/FolderTest.php b/tests/FolderTest.php
index f979bb982fe61c4a25b2305b3bffe895408be46c..73d8fe64e3d4ff7cf00610a42369531f1f1f08c0 100644
--- a/tests/FolderTest.php
+++ b/tests/FolderTest.php
@@ -23,7 +23,6 @@ namespace OCA\Mail\Tests;
 
 use ChristophWurst\Nextcloud\Testing\TestCase;
 use Horde_Imap_Client_Mailbox;
-use OCA\Mail\Account;
 use OCA\Mail\Folder;
 use PHPUnit_Framework_MockObject_MockObject;
 
diff --git a/tests/Integration/IMAP/AccountTest.php b/tests/Integration/IMAP/AccountTest.php
index ed484af3f0d3ba042c746cdd0183e44ad2ad8856..e3779082b0900a8e341f4c97fdbd47f19bfd670d 100644
--- a/tests/Integration/IMAP/AccountTest.php
+++ b/tests/Integration/IMAP/AccountTest.php
@@ -24,7 +24,6 @@
 
 namespace OCA\Mail\Tests\Integration\IMAP;
 
-use OCA\Mail\Tests\Integration\IMAP\AbstractTest;
 
 /**
  * @group IMAP
diff --git a/tests/Integration/Service/Avatar/FaviconSourceTest.php b/tests/Integration/Service/Avatar/FaviconSourceTest.php
index f65b7552d8d759d2cb578d49f0187eaebd2ccf2e..dfbad9f4eea7c2f8450379213664f62f4d2a95ed 100644
--- a/tests/Integration/Service/Avatar/FaviconSourceTest.php
+++ b/tests/Integration/Service/Avatar/FaviconSourceTest.php
@@ -30,11 +30,8 @@ use OCA\Mail\Service\Avatar\AvatarFactory;
 use OCA\Mail\Service\Avatar\FaviconSource;
 use ChristophWurst\Nextcloud\Testing\TestCase;
 use OCP\Files\IMimeTypeDetector;
-use OCP\Http\Client\IClient;
 use OCP\Http\Client\IClientService;
-use OCP\Http\Client\IResponse;
 use OCP\IServerContainer;
-use PHPUnit\Framework\MockObject\MockObject;
 use function iterator_to_array;
 use function unlink;
 
diff --git a/tests/Unit/Controller/ProxyControllerTest.php b/tests/Unit/Controller/ProxyControllerTest.php
index f3bda3d9488597c76d098f52f6843020e5cb693f..e78cb9c958b98197368c959d785ae95a6c44fa51 100644
--- a/tests/Unit/Controller/ProxyControllerTest.php
+++ b/tests/Unit/Controller/ProxyControllerTest.php
@@ -21,7 +21,6 @@
 
 namespace OCA\Mail\Tests\Unit\Controller;
 
-use ArrayAccess;
 use ChristophWurst\Nextcloud\Testing\TestCase;
 use Exception;
 use OCA\Mail\Controller\ProxyController;
diff --git a/tests/Unit/Service/Autoconfig/ImapConnectorTest.php b/tests/Unit/Service/Autoconfig/ImapConnectorTest.php
index 283ae653d8bf56adb38ce3219307d66bd2c000e1..889917126246521b5c08cc8e2e5ecf13d9b37bc3 100644
--- a/tests/Unit/Service/Autoconfig/ImapConnectorTest.php
+++ b/tests/Unit/Service/Autoconfig/ImapConnectorTest.php
@@ -23,15 +23,12 @@ namespace OCA\Mail\Tests\Unit\Service\Autoconfig;
 
 use ChristophWurst\Nextcloud\Testing\TestCase;
 use Horde_Imap_Client_Exception;
-use OC;
-use OCA\Mail\Account;
 use OCA\Mail\Db\MailAccount;
 use OCA\Mail\IMAP\IMAPClientFactory;
 use OCA\Mail\Service\AutoConfig\ImapConnector;
 use OCP\ILogger;
 use OCP\Security\ICrypto;
 use PHPUnit\Framework\MockObject\MockObject;
-use PHPUnit_Framework_MockObject_MockObject;
 
 class ImapConnectorTest extends TestCase {
 
diff --git a/tests/Unit/Service/MailTransmissionTest.php b/tests/Unit/Service/MailTransmissionTest.php
index ed1ab301b1761100cee8002fadc99c8cdcead540..b609c8885dbd43c1a9fdbe1ca1f82a2a4c910976 100644
--- a/tests/Unit/Service/MailTransmissionTest.php
+++ b/tests/Unit/Service/MailTransmissionTest.php
@@ -31,9 +31,7 @@ use OCA\Mail\Db\Alias;
 use OCA\Mail\Db\MailboxMapper;
 use OCA\Mail\IMAP\IMAPClientFactory;
 use OCA\Mail\IMAP\MessageMapper;
-use OCA\Mail\Mailbox;
 use OCA\Mail\Model\IMAPMessage;
-use OCA\Mail\Model\IMessage;
 use OCA\Mail\Model\Message;
 use OCA\Mail\Model\NewMessageData;
 use OCA\Mail\Model\RepliedMessageData;