import zmail
from PyQt5.QtWidgets import QApplication, QMainWindow, QTreeWidget, QTreeWidgetItem, QPushButton
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
self.init()
def initUI(self):
# Create a tree widget and set its columns
self.tree = QTreeWidget(self)
self.tree.setColumnCount(4)
self.tree.setHeaderLabels(["Index", "Account", "Password", "Status"])
# Create a button to insert a new item
#self.button = QPushButton("Insert", self)
#self.button.clicked.connect(self.insert_item)
# Set the layout
self.setCentralWidget(self.tree)
#self.button.move(0, 0)
def insert_item(self):
# Insert a new item into the tree widget with default values
item = QTreeWidgetItem(self.tree, ["", "", "", ""])
self.tree.addTopLevelItem(item)
def init(self):
index = 0
dict = {'邮箱号': '邮箱密码'}
for mail in dict:
index = index+1
server = zmail.server(mail, dict[mail], timeout=3)
if server.pop_able():
print("登录成功:"+mail)
content = server.get_latest()
print(content['content_html'])
item = QTreeWidgetItem(
self.tree, [str(index), mail, dict[mail], "成功"])
else:
print("登录失败:"+mail)
item = QTreeWidgetItem(
self.tree, [str(index), mail, dict[mail], "失败"])
self.tree.addTopLevelItem(item)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())