python:PyQt5 开发一个邮件客户端,能编写邮件,发送邮件及附件

PyQt5 邮件客户端

下面是一个简洁高效的邮件客户端实现,支持编写邮件、添加附件和发送邮件功能:
编写 eMailClient_qt.py 如下

# -*- coding: utf-8 -*-
""" 用 PyQt5 开发一个邮件客户端,能编写邮件,发送邮件及附件 """
import os
import sys
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, 
                             QVBoxLayout, QHBoxLayout, QFileDialog,
                             QLineEdit, QTextEdit, QPushButton, QLabel,
                             QListWidget, QMessageBox, QStatusBar, QGridLayout)
from PyQt5.QtGui import QFont, QPalette, QColor
from PyQt5.QtCore import Qt, QSize

class EmailClient(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("邮件客户端")
        # 设置窗口大小为1000x600
        self.setGeometry(100, 100, 1000, 600)
        
        # 设置现代化UI样式
        self.setStyleSheet("""
            QMainWindow {
                background-color: #f0f2f5;
            }
            QLabel {
                color: #333;
                font-size: 12px;
                font-weight: bold;
                padding: 2px 0;
            }
            QLineEdit, QTextEdit {
                background-color: white;
                border: 1px solid #dcdfe6;
                border-radius: 4px;
                padding: 8px;
                font-size: 13px;
            }
            QLineEdit:focus, QTextEdit:focus {
                border: 1px solid #4a90e2;
            }
            QPushButton {
                background-color: #4a90e2;
                color: white;
                border: none;
                border-radius: 4px;
                padding: 8px 15px;
                font-size: 13px;
                min-height: 30px;
            }
            QPushButton:hover {
                background-color: #3a7bc8;
            }
            QPushButton:pressed {
                background-color: #2a65a8;
            }
            QPushButton#attachButton {
                background-color: #f5f7fa;
                color: #4a90e2;
                border: 1px solid #4a90e2;
            }
            QPushButton#sendButton {
                background-color: #27ae60;
                padding: 10px 25px;
                font-size: 14px;
                font-weight: bold;
            }
            QPushButton#sendButton:hover {
                background-color: #219653;
            }
            QListWidget {
                background-color: white;
                border: 1px solid #dcdfe6;
                border-radius: 4px;
                padding: 5px;
                font-size: 12px;
                alternate-background-color: #f8f9fa;
            }
            QStatusBar {
                background-color: #e0e6ed;
                color: #666;
                font-size: 11px;
                padding: 5px;
            }
            QFrame#headerFrame {
                background-color: #4a90e2;
                border-radius: 5px;
                padding: 10px;
            }
        """)
        
        # 创建中央部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        
        # 主布局 - 使用网格布局更灵活
        main_layout = QGridLayout(central_widget)
        main_layout.setSpacing(15)
        main_layout.setContentsMargins(15, 15, 15, 15)
        
        # 标题区域
        title_label = QLabel("邮件客户端")
        title_label.setFont(QFont("Arial", 18, QFont.Bold))
        title_label.setStyleSheet("color: #2c3e50;")
        main_layout.addWidget(title_label, 0, 0, 1, 3, alignment=Qt.AlignLeft)
        
        # 发件人信息
        main_layout.addWidget(QLabel("发件人:"), 1, 0, alignment=Qt.AlignRight)
        
        self.sender_email = QLineEdit()
        self.sender_email.setPlaceholderText("your_email@qq.com")
        main_layout.addWidget(self.sender_email, 1, 1, 1, 2)
        
        main_layout.addWidget(QLabel("密码:"), 1, 3, alignment=Qt.AlignRight)
        
        self.password = QLineEdit()
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setPlaceholderText("邮箱密码或应用密码")
        main_layout.addWidget(self.password, 1, 4)
        
        # 收件人 - 标签和输入框在同一行
        main_layout.addWidget(QLabel("收件人:"), 2, 0, alignment=Qt.AlignRight)
        
        self.recipient_email = QLineEdit()
        self.recipient_email.setPlaceholderText("recipient@qq.com")
        main_layout.addWidget(self.recipient_email, 2, 1, 1, 4)
        
        # 主题 - 标签和输入框在同一行
        main_layout.addWidget(QLabel("主题:"), 3, 0, alignment=Qt.AlignRight)
        
        self.subject = QLineEdit()
        self.subject.setPlaceholderText("邮件主题")
        main_layout.addWidget(self.subject, 3, 1, 1, 4)
        
        # 附件
        main_layout.addWidget(QLabel("附件:"), 4, 0, alignment=Qt.AlignRight | Qt.AlignTop)
        
        # 附件列表和按钮
        attachment_widget = QWidget()
        attachment_layout = QVBoxLayout(attachment_widget)
        
        self.attachment_list = QListWidget()
        self.attachment_list.setMinimumHeight(80)
        attachment_layout.addWidget(self.attachment_list)
        
        # 按钮布局
        btn_layout = QHBoxLayout()
        attach_button = QPushButton("添加附件")
        attach_button.setObjectName("attachButton")
        attach_button.clicked.connect(self.add_attachment)
        btn_layout.addWidget(attach_button)
        
        remove_button = QPushButton("移除附件")
        remove_button.setObjectName("attachButton")
        remove_button.clicked.connect(self.remove_attachment)
        btn_layout.addWidget(remove_button)
        
        attachment_layout.addLayout(btn_layout)
        main_layout.addWidget(attachment_widget, 4, 1, 1, 4)
        
        # 邮件正文 - 扩大区域
        main_layout.addWidget(QLabel("正文:"), 5, 0, alignment=Qt.AlignRight | Qt.AlignTop)
        
        self.body = QTextEdit()
        self.body.setPlaceholderText("在此输入邮件内容...")
        # 设置正文区域的行数(相对扩大)
        main_layout.addWidget(self.body, 5, 1, 1, 4)
        
        # 发送按钮
        send_button = QPushButton("发送邮件")
        send_button.setObjectName("sendButton")
        send_button.clicked.connect(self.send_email)
        main_layout.addWidget(send_button, 6, 4, alignment=Qt.AlignRight)
        
        # 设置行和列的比例,使正文区域扩大
        main_layout.setRowStretch(5, 3)  # 正文区域行权重设为3
        main_layout.setColumnStretch(1, 1)
        main_layout.setColumnStretch(2, 1)
        main_layout.setColumnStretch(3, 1)
        main_layout.setColumnStretch(4, 2)  # 右侧列权重更大
        
        # 状态栏
        self.status_bar = QStatusBar()
        self.setStatusBar(self.status_bar)
        self.status_bar.showMessage(f"就绪 - 窗口大小: {self.width()}x{self.height()}")
        
        # 存储附件路径
        self.attachments = []
        
        # 设置示例数据
        self.sender_email.setText("your_email@qq.com")
        self.recipient_email.setText("recipient@qq.com")
        self.subject.setText("PyQt5 邮件客户端测试")
        self.body.setPlainText(
            "这是一封测试邮件,使用 PyQt5 邮件客户端发送。\n\n"
            "此邮件支持添加多个附件,并采用现代化的界面设计。\n\n"
            "功能包括:\n"
            "• 邮件编写\n"
            "• 附件添加/移除\n"
            "• 邮件发送\n"
            "• 状态反馈\n\n"
            "祝您使用愉快!"
        )
    
    def add_attachment(self):
        files, _ = QFileDialog.getOpenFileNames(self, "选择附件", "", "所有文件 (*.*)")
        if files:
            self.attachments.extend(files)
            self.attachment_list.addItems(files)
            self.status_bar.showMessage(f"已添加 {len(files)} 个附件")
    
    def remove_attachment(self):
        current_row = self.attachment_list.currentRow()
        if current_row >= 0:
            item = self.attachment_list.takeItem(current_row)
            del self.attachments[current_row]
            self.status_bar.showMessage(f"已移除附件: {item.text()}")
        else:
            self.status_bar.showMessage("请选择要移除的附件")
    
    def send_email(self):
        sender = self.sender_email.text()
        password = self.password.text()
        recipient = self.recipient_email.text()
        subject = self.subject.text()
        body = self.body.toPlainText()  # 使用纯文本格式
        
        if not sender or not password or not recipient:
            QMessageBox.warning(self, "输入错误", "请填写完整的发件人、密码和收件人信息")
            return
        
        try:
            # 创建邮件对象
            msg = MIMEMultipart()
            msg['From'] = sender
            msg['To'] = recipient
            msg['Subject'] = subject
            
            # 添加邮件正文
            msg.attach(MIMEText(body, 'plain'))
            
            # 添加附件
            for file_path in self.attachments:
                try:
                    with open(file_path, "rb") as attachment:
                        part = MIMEBase("application", "octet-stream")
                        part.set_payload(attachment.read())
                    encoders.encode_base64(part)
                    # 获取文件名
                    filename = file_path.split('/')[-1] if '/' in file_path else file_path
                    filename = filename.split('\\')[-1]  # 处理Windows路径
                    part.add_header(
                        "Content-Disposition",
                        f"attachment; filename={filename}",
                    )
                    msg.attach(part)
                except Exception as e:
                    self.status_bar.showMessage(f"添加附件失败: {str(e)}")
                    return
            
            # 连接SMTP服务器并发送邮件
            self.status_bar.showMessage("正在连接服务器...")
            server = smtplib.SMTP_SSL('smtp.gmail.com', 465)  # 使用Gmail SMTP服务器
            self.status_bar.showMessage("正在登录...")
            server.login(sender, password)
            self.status_bar.showMessage("正在发送邮件...")
            server.sendmail(sender, recipient, msg.as_string())
            server.quit()
            
            # 发送成功后的操作
            self.status_bar.showMessage("邮件发送成功!")
            QMessageBox.information(self, "发送成功", "邮件已成功发送!")
            
            # 清空附件列表
            self.attachment_list.clear()
            self.attachments = []
            
        except smtplib.SMTPAuthenticationError:
            QMessageBox.critical(self, "认证失败", "邮箱或密码错误,请检查您的登录信息")
            self.status_bar.showMessage("认证失败")
        except Exception as e:
            QMessageBox.critical(self, "发送失败", f"邮件发送失败: {str(e)}")
            self.status_bar.showMessage(f"发送失败: {str(e)}")
    
    def resizeEvent(self, event):
        """窗口大小改变时更新状态栏信息"""
        self.status_bar.showMessage(f"就绪 - 窗口大小: {self.width()}x{self.height()}")
        super().resizeEvent(event)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    
    # 设置应用样式
    palette = QPalette()
    palette.setColor(QPalette.Window, QColor(240, 242, 245))
    palette.setColor(QPalette.WindowText, QColor(51, 51, 51))
    palette.setColor(QPalette.Base, QColor(255, 255, 255))
    palette.setColor(QPalette.AlternateBase, QColor(248, 249, 250))
    palette.setColor(QPalette.Button, QColor(74, 144, 226))
    palette.setColor(QPalette.ButtonText, QColor(255, 255, 255))
    palette.setColor(QPalette.Highlight, QColor(74, 144, 226))
    palette.setColor(QPalette.HighlightedText, QColor(255, 255, 255))
    app.setPalette(palette)
    
    client = EmailClient()
    client.show()
    sys.exit(app.exec_())

功能说明

这个邮件客户端实现了以下核心功能:

  1. 邮件编写

    • 发件人邮箱和密码输入
    • 收件人地址输入
    • 邮件主题输入
    • 邮件正文编辑区域
  2. 附件管理

    • 添加多个附件
    • 查看附件列表
    • 移除选中的附件
  3. 邮件发送

    • 使用SMTP协议发送邮件
    • 支持纯文本格式的邮件内容
    • 支持发送多个附件
    • 错误处理和状态反馈

使用说明

  1. 在"发件人"字段输入您的邮箱地址
  2. 在"密码"字段输入您的邮箱密码(或应用专用密码)
  3. 在"收件人"字段输入收件人邮箱地址
  4. 填写邮件主题和正文内容
  5. 点击"添加附件"按钮选择要发送的文件
  6. 点击"发送邮件"按钮发送邮件

注意事项

  1. 该程序默认使用Gmail的SMTP服务器(smtp.gmail.com:465),如果您使用其他邮箱服务:

    • QQ邮箱:smtp.qq.com:465
    • 163邮箱:smtp.163.com:465
    • Outlook:smtp.office365.com:587(需要使用TLS)
  2. 部分邮箱服务需要开启SMTP服务并获取授权码:

    • Gmail:需要在账户设置中开启"安全性较低的应用的访问权限"
    • QQ/163:需要在邮箱设置中开启SMTP服务并获取授权码
  3. 出于安全考虑,程序不会保存您的密码,每次发送邮件都需要输入

这个程序提供了一个简洁高效的邮件发送解决方案,代码结构清晰,去除了不必要的装饰元素,专注于核心功能的实现。

eMailClient_qt


PyQt5 邮件客户端 - 优化布局

下面是一个优化布局的邮件客户端实现,窗口大小调整为1000x600,提供更舒适的编辑体验:
编写 eMailClient_qt5.py 如下

import sys
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
                             QLineEdit, QTextEdit, QPushButton, QLabel, QFileDialog,
                             QListWidget, QMessageBox, QStatusBar, QSplitter, QFrame)
from PyQt5.QtGui import QFont, QPalette, QColor
from PyQt5.QtCore import Qt

class EmailClient(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("邮件客户端")
        # 设置窗口大小为1000x600
        self.setGeometry(100, 100, 1000, 600)
        
        # 设置现代化UI样式
        self.setStyleSheet("""
            QMainWindow {
                background-color: #f0f2f5;
            }
            QLabel {
                color: #333;
                font-size: 12px;
                font-weight: bold;
                padding: 2px 0;
            }
            QLineEdit, QTextEdit {
                background-color: white;
                border: 1px solid #dcdfe6;
                border-radius: 4px;
                padding: 8px;
                font-size: 13px;
            }
            QLineEdit:focus, QTextEdit:focus {
                border: 1px solid #4a90e2;
            }
            QPushButton {
                background-color: #4a90e2;
                color: white;
                border: none;
                border-radius: 4px;
                padding: 8px 15px;
                font-size: 13px;
                min-height: 30px;
            }
            QPushButton:hover {
                background-color: #3a7bc8;
            }
            QPushButton:pressed {
                background-color: #2a65a8;
            }
            QPushButton#attachButton {
                background-color: #f5f7fa;
                color: #4a90e2;
                border: 1px solid #4a90e2;
            }
            QPushButton#sendButton {
                background-color: #27ae60;
                padding: 10px 25px;
                font-size: 14px;
                font-weight: bold;
            }
            QPushButton#sendButton:hover {
                background-color: #219653;
            }
            QListWidget {
                background-color: white;
                border: 1px solid #dcdfe6;
                border-radius: 4px;
                padding: 5px;
                font-size: 12px;
                alternate-background-color: #f8f9fa;
            }
            QStatusBar {
                background-color: #e0e6ed;
                color: #666;
                font-size: 11px;
                padding: 5px;
            }
            QFrame#headerFrame {
                background-color: #4a90e2;
                border-radius: 5px;
                padding: 10px;
            }
        """)
        
        # 创建中央部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)
        
        # 主布局
        main_layout = QVBoxLayout(central_widget)
        main_layout.setSpacing(15)
        main_layout.setContentsMargins(15, 15, 15, 15)
        
        # 标题区域
        header_frame = QFrame()
        header_frame.setObjectName("headerFrame")
        header_layout = QHBoxLayout(header_frame)
        header_layout.setContentsMargins(10, 5, 10, 5)
        
        title_label = QLabel("邮件客户端")
        title_label.setFont(QFont("Arial", 18, QFont.Bold))
        title_label.setStyleSheet("color: white;")
        header_layout.addWidget(title_label)
        header_layout.addStretch()
        
        main_layout.addWidget(header_frame)
        
        # 创建分割器,左侧为设置区域,右侧为编辑区域
        splitter = QSplitter(Qt.Horizontal)
        main_layout.addWidget(splitter, 1)
        
        # 左侧设置面板
        settings_panel = QWidget()
        settings_layout = QVBoxLayout(settings_panel)
        settings_layout.setContentsMargins(0, 0, 10, 0)
        
        # 发件人信息
        sender_group = QWidget()
        sender_layout = QVBoxLayout(sender_group)
        sender_layout.addWidget(QLabel("发件人设置"))
        
        sender_form = QHBoxLayout()
        sender_form.addWidget(QLabel("邮箱:"))
        self.sender_email = QLineEdit()
        self.sender_email.setPlaceholderText("your_email@example.com")
        sender_form.addWidget(self.sender_email)
        sender_layout.addLayout(sender_form)
        
        sender_form2 = QHBoxLayout()
        sender_form2.addWidget(QLabel("密码:"))
        self.password = QLineEdit()
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setPlaceholderText("邮箱密码或应用密码")
        sender_form2.addWidget(self.password)
        sender_layout.addLayout(sender_form2)
        
        settings_layout.addWidget(sender_group)
        
        # 收件人
        recipient_group = QWidget()
        recipient_layout = QVBoxLayout(recipient_group)
        recipient_layout.addWidget(QLabel("收件人"))
        self.recipient_email = QLineEdit()
        self.recipient_email.setPlaceholderText("recipient@example.com")
        recipient_layout.addWidget(self.recipient_email)
        settings_layout.addWidget(recipient_group)
        
        # 主题
        subject_group = QWidget()
        subject_layout = QVBoxLayout(subject_group)
        subject_layout.addWidget(QLabel("主题"))
        self.subject = QLineEdit()
        self.subject.setPlaceholderText("邮件主题")
        subject_layout.addWidget(self.subject)
        settings_layout.addWidget(subject_group)
        
        # 附件
        attachment_group = QWidget()
        attachment_layout = QVBoxLayout(attachment_group)
        attachment_layout.addWidget(QLabel("附件"))
        
        # 附件列表
        self.attachment_list = QListWidget()
        self.attachment_list.setMinimumHeight(100)
        attachment_layout.addWidget(self.attachment_list)
        
        # 附件按钮
        btn_layout = QHBoxLayout()
        attach_button = QPushButton("添加附件")
        attach_button.setObjectName("attachButton")
        attach_button.clicked.connect(self.add_attachment)
        btn_layout.addWidget(attach_button)
        
        remove_button = QPushButton("移除附件")
        remove_button.setObjectName("attachButton")
        remove_button.clicked.connect(self.remove_attachment)
        btn_layout.addWidget(remove_button)
        attachment_layout.addLayout(btn_layout)
        
        settings_layout.addWidget(attachment_group)
        settings_layout.addStretch()
        
        # 右侧编辑区域
        editor_panel = QWidget()
        editor_layout = QVBoxLayout(editor_panel)
        editor_layout.setContentsMargins(0, 0, 0, 0)
        
        # 邮件正文
        editor_layout.addWidget(QLabel("邮件正文"))
        self.body = QTextEdit()
        self.body.setPlaceholderText("在此输入邮件内容...")
        editor_layout.addWidget(self.body, 1)
        
        # 发送按钮
        send_button = QPushButton("发送邮件")
        send_button.setObjectName("sendButton")
        send_button.clicked.connect(self.send_email)
        editor_layout.addWidget(send_button, 0, Qt.AlignRight)
        
        # 添加左右面板到分割器
        splitter.addWidget(settings_panel)
        splitter.addWidget(editor_panel)
        splitter.setSizes([300, 700])
        
        # 状态栏
        self.status_bar = QStatusBar()
        self.setStatusBar(self.status_bar)
        self.status_bar.showMessage("就绪 - 窗口大小: 1000x600")
        
        # 存储附件路径
        self.attachments = []
        
        # 设置示例数据
        self.sender_email.setText("your_email@example.com")
        self.recipient_email.setText("recipient@example.com")
        self.subject.setText("PyQt5 邮件客户端测试")
        self.body.setPlainText(
            "这是一封测试邮件,使用 PyQt5 邮件客户端发送。\n\n"
            "此邮件支持添加多个附件,并采用现代化的界面设计。\n\n"
            "功能包括:\n"
            "• 邮件编写\n"
            "• 附件添加/移除\n"
            "• 邮件发送\n"
            "• 状态反馈\n\n"
            "祝您使用愉快!"
        )
    
    def add_attachment(self):
        files, _ = QFileDialog.getOpenFileNames(self, "选择附件", "", "所有文件 (*.*)")
        if files:
            self.attachments.extend(files)
            self.attachment_list.addItems(files)
            self.status_bar.showMessage(f"已添加 {len(files)} 个附件")
    
    def remove_attachment(self):
        current_row = self.attachment_list.currentRow()
        if current_row >= 0:
            item = self.attachment_list.takeItem(current_row)
            del self.attachments[current_row]
            self.status_bar.showMessage(f"已移除附件: {item.text()}")
        else:
            self.status_bar.showMessage("请选择要移除的附件")
    
    def send_email(self):
        sender = self.sender_email.text()
        password = self.password.text()
        recipient = self.recipient_email.text()
        subject = self.subject.text()
        body = self.body.toPlainText()  # 使用纯文本格式
        
        if not sender or not password or not recipient:
            QMessageBox.warning(self, "输入错误", "请填写完整的发件人、密码和收件人信息")
            return
        
        try:
            # 创建邮件对象
            msg = MIMEMultipart()
            msg['From'] = sender
            msg['To'] = recipient
            msg['Subject'] = subject
            
            # 添加邮件正文
            msg.attach(MIMEText(body, 'plain'))
            
            # 添加附件
            for file_path in self.attachments:
                try:
                    with open(file_path, "rb") as attachment:
                        part = MIMEBase("application", "octet-stream")
                        part.set_payload(attachment.read())
                    encoders.encode_base64(part)
                    # 获取文件名
                    filename = file_path.split('/')[-1] if '/' in file_path else file_path
                    filename = filename.split('\\')[-1]  # 处理Windows路径
                    part.add_header(
                        "Content-Disposition",
                        f"attachment; filename={filename}",
                    )
                    msg.attach(part)
                except Exception as e:
                    self.status_bar.showMessage(f"添加附件失败: {str(e)}")
                    return
            
            # 连接SMTP服务器并发送邮件
            self.status_bar.showMessage("正在连接服务器...")
            server = smtplib.SMTP_SSL('smtp.gmail.com', 465)  # 使用Gmail SMTP服务器
            self.status_bar.showMessage("正在登录...")
            server.login(sender, password)
            self.status_bar.showMessage("正在发送邮件...")
            server.sendmail(sender, recipient, msg.as_string())
            server.quit()
            
            # 发送成功后的操作
            self.status_bar.showMessage("邮件发送成功!")
            QMessageBox.information(self, "发送成功", "邮件已成功发送!")
            
            # 清空附件列表
            self.attachment_list.clear()
            self.attachments = []
            
        except smtplib.SMTPAuthenticationError:
            QMessageBox.critical(self, "认证失败", "邮箱或密码错误,请检查您的登录信息")
            self.status_bar.showMessage("认证失败")
        except Exception as e:
            QMessageBox.critical(self, "发送失败", f"邮件发送失败: {str(e)}")
            self.status_bar.showMessage(f"发送失败: {str(e)}")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    
    # 设置应用样式
    palette = QPalette()
    palette.setColor(QPalette.Window, QColor(240, 242, 245))
    palette.setColor(QPalette.WindowText, QColor(51, 51, 51))
    palette.setColor(QPalette.Base, QColor(255, 255, 255))
    palette.setColor(QPalette.AlternateBase, QColor(248, 249, 250))
    palette.setColor(QPalette.Button, QColor(74, 144, 226))
    palette.setColor(QPalette.ButtonText, QColor(255, 255, 255))
    palette.setColor(QPalette.Highlight, QColor(74, 144, 226))
    palette.setColor(QPalette.HighlightedText, QColor(255, 255, 255))
    app.setPalette(palette)
    
    client = EmailClient()
    client.show()
    sys.exit(app.exec_())

功能说明

这个邮件客户端具有以下特点:

  1. 现代化UI设计

    • 蓝色主题与现代化界面元素
    • 分割布局(左侧设置区,右侧编辑区)
    • 响应式设计,适应1000x600窗口尺寸
  2. 邮件功能

    • 完整的邮件编写功能
    • 多附件支持(添加/移除)
    • SMTP邮件发送
  3. 用户体验优化

    • 状态提示(连接、登录、发送状态)
    • 详细的错误反馈
    • 清晰的视觉层次结构
  4. 布局优化

    • 左侧设置面板:发件人信息、收件人、主题、附件管理
    • 右侧编辑面板:邮件正文编辑区域
    • 底部状态栏:显示操作状态和反馈

使用说明

  1. 左侧设置面板

    • 输入发件人邮箱和密码
    • 输入收件人邮箱地址
    • 填写邮件主题
    • 管理附件(添加/移除)
  2. 右侧编辑面板

    • 在正文区域编写邮件内容
    • 点击"发送邮件"按钮发送
  3. 状态反馈

    • 状态栏显示当前操作状态
    • 发送成功/失败会有弹窗提示

技术特点

  1. 窗口尺寸

    • 主窗口设置为1000x600像素,提供宽敞的编辑空间
    • 使用QSplitter实现可调整大小的面板
  2. 邮件发送

    • 支持Gmail SMTP服务器(可修改为其他服务商)
    • 支持纯文本邮件内容
    • 支持多个附件发送
  3. 错误处理

    • 详细的错误捕获和反馈
    • 认证失败、发送失败等情况的专门处理

这个邮件客户端在保持功能完整性的同时,提供了更加现代化和专业的用户界面,充分利用了1000x600的窗口空间,为用户带来更舒适的邮件编辑体验。

eMailClient_qt5

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值