File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,11 +94,29 @@ void SendEmail::on_sendEmail_clicked()
9494void SendEmail::sendMailAsync (const MimeMessage &msg)
9595{
9696 qDebug () << " sendMailAsync" ;
97- auto server = new Server (this );
98- server->setHost (ui->host ->text ());
99- server->setPort (quint16 (ui->port ->value ()));
100- server->setConnectionType (ui->security ->currentIndex () == 0 ? Server::TcpConnection :
101- ui->security ->currentIndex () == 1 ? Server::SslConnection : Server::TlsConnection);
97+
98+ const QString host = ui->host ->text ();
99+ const quint16 port (ui->port ->value ());
100+ const Server::ConnectionType ct = ui->security ->currentIndex () == 0 ?
101+ Server::TcpConnection : ui->security ->currentIndex () == 1 ?
102+ Server::SslConnection : Server::TlsConnection;
103+
104+ Server *server = nullptr ;
105+ for (auto srv : m_aServers) {
106+ if (srv->host () == host && srv->port () == port & srv->connectionType () == ct) {
107+ server = srv;
108+ break ;
109+ }
110+ }
111+
112+ if (!server) {
113+ server = new Server (this );
114+ server->setHost (host);
115+ server->setPort (port);
116+ server->setConnectionType (ct);
117+ m_aServers.push_back (server);
118+ }
119+
102120 const QString user = ui->username ->text ();
103121 if (!user.isEmpty ()) {
104122 server->setAuthMethod (Server::AuthLogin);
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ namespace Ui {
2626 class SendEmail ;
2727}
2828
29+ namespace SimpleMail {
30+ class Server ;
31+ }
32+
2933using namespace SimpleMail ;
3034
3135class SendEmail : public QWidget
@@ -45,6 +49,7 @@ private Q_SLOTS:
4549
4650private:
4751 QSettings m_settings;
52+ std::vector<Server *> m_aServers;
4853 Ui::SendEmail *ui;
4954
5055 void errorMessage (const QString & message);
You can’t perform that action at this time.
0 commit comments