57 Preferences.setUser("MailServerPassword", |
65 Preferences.setUser("MailServerPassword", |
58 self.mailPasswordEdit.text()) |
66 self.mailPasswordEdit.text()) |
59 Preferences.setUser("MailServerUseTLS", |
67 Preferences.setUser("MailServerUseTLS", |
60 self.useTlsCheckBox.isChecked()) |
68 self.useTlsCheckBox.isChecked()) |
61 |
69 |
|
70 |
|
71 def __updateTestButton(self): |
|
72 """ |
|
73 Private slot to update the enabled state of the test button. |
|
74 """ |
|
75 self.testButton.setEnabled( |
|
76 self.mailAuthenticationCheckBox.isChecked() and \ |
|
77 self.mailUserEdit.text() != "" and \ |
|
78 self.mailPasswordEdit.text() != "" and \ |
|
79 self.mailServerEdit.text() != "" |
|
80 ) |
|
81 |
|
82 @pyqtSlot(bool) |
|
83 def on_mailAuthenticationCheckBox_toggled(self, checked): |
|
84 """ |
|
85 Private slot to handle a change of the state of the authentication |
|
86 selector. |
|
87 |
|
88 @param checked state of the checkbox (boolean) |
|
89 """ |
|
90 self.__updateTestButton() |
|
91 |
|
92 @pyqtSlot(str) |
|
93 def on_mailUserEdit_textChanged(self, txt): |
|
94 """ |
|
95 Private slot to handle a change of the text of the user edit. |
|
96 |
|
97 @param txt current text of the edit (string) |
|
98 """ |
|
99 self.__updateTestButton() |
|
100 |
|
101 @pyqtSlot(str) |
|
102 def on_mailPasswordEdit_textChanged(self, txt): |
|
103 """ |
|
104 Private slot to handle a change of the text of the user edit. |
|
105 |
|
106 @param txt current text of the edit (string) |
|
107 """ |
|
108 self.__updateTestButton() |
|
109 |
|
110 @pyqtSlot() |
|
111 def on_testButton_clicked(self): |
|
112 """ |
|
113 Private slot to test the mail server login data. |
|
114 """ |
|
115 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
|
116 QApplication.processEvents() |
|
117 try: |
|
118 server = smtplib.SMTP(self.mailServerEdit.text(), |
|
119 self.portSpin.value(), |
|
120 "", 10) |
|
121 if self.useTlsCheckBox.isChecked(): |
|
122 server.starttls() |
|
123 try: |
|
124 server.login(self.mailUserEdit.text(), |
|
125 self.mailPasswordEdit.text()) |
|
126 QApplication.restoreOverrideCursor() |
|
127 E5MessageBox.information(self, |
|
128 self.trUtf8("Login Test"), |
|
129 self.trUtf8("""The login test succeeded.""")) |
|
130 except (smtplib.SMTPException, socket.error) as e: |
|
131 QApplication.restoreOverrideCursor() |
|
132 if isinstance(e, smtplib.SMTPResponseException): |
|
133 errorStr = e.smtp_error.decode() |
|
134 elif isinstance(e, socket.timeout): |
|
135 errorStr = str(e) |
|
136 elif isinstance(e, socket.error): |
|
137 errorStr = e[1] |
|
138 else: |
|
139 errorStr = str(e) |
|
140 E5MessageBox.critical(self, |
|
141 self.trUtf8("Login Test"), |
|
142 self.trUtf8("""<p>The login test failed.<br>Reason: {0}</p>""") |
|
143 .format(errorStr)) |
|
144 server.quit() |
|
145 except (smtplib.SMTPException, socket.error) as e: |
|
146 QApplication.restoreOverrideCursor() |
|
147 if isinstance(e, smtplib.SMTPResponseException): |
|
148 errorStr = e.smtp_error.decode() |
|
149 elif isinstance(e, socket.timeout): |
|
150 errorStr = str(e) |
|
151 elif isinstance(e, socket.error): |
|
152 errorStr = e[1] |
|
153 else: |
|
154 errorStr = str(e) |
|
155 E5MessageBox.critical(self, |
|
156 self.trUtf8("Login Test"), |
|
157 self.trUtf8("""<p>The login test failed.<br>Reason: {0}</p>""") |
|
158 .format(errorStr)) |
62 |
159 |
63 def create(dlg): |
160 def create(dlg): |
64 """ |
161 """ |
65 Module function to create the configuration page. |
162 Module function to create the configuration page. |
66 |
163 |