# SmtpClient-for-Qt-v2.0 **Repository Path**: feifei2864/SmtpClient-for-Qt-v2.0 ## Basic Information - **Project Name**: SmtpClient-for-Qt-v2.0 - **Description**: No description available - **Primary Language**: Unknown - **License**: LGPL-2.1 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-08-20 - **Last Updated**: 2024-08-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README SMTP Client for Qt (C++) - 版本2.0![Linux Build](https://github.com/bluetiger9/SmtpClient-for-Qt/actions/workflows/linux-build.yml/badge.svg) ============================================= SmtpClient for Qt是为Qt 5 / 6(C++版本)编写的小型库,允许应用程序使用简单邮件传输协议(SMTP)发送复杂的电子邮件(纯文本,html,附件,内联文件等)。 ## 2.0 新版功能: - 异步和同步工作模式 Qt5/6 兼容性 - 构建为共享库 - SmtpClient的代码被重构并部分重写 ## 1.1 新版功能: - 现在支持 TLS (STARTTLS) 连接 - 多种类型的收件人(收件人、抄送、密件抄送) - 嵌套的 MIME 电子邮件(混合/另类、混合/相关) - 输出编译与RFC2045 ## SMTP Client for Qt支持 - 到 SMTP 服务器的 TCP 和 SSL 连接 - SMTP 身份验证(PLAIN 和 LOGIN 方法) - 发送 MIME 电子邮件(发送给多个收件人) - 电子邮件中的纯文本和 HTML(包含内联文件)内容 - 多个附件和内联文件(在 HTML 中使用) - 不同的字符集(ASCII、UTF-8 等)和编码方式(7bit、8bit、base64) - 错误处理 ## 例子 让我们看一个简单的例子: ```c++ #include #include "../src/SmtpMime" int main(int argc, char *argv[]) { { QCoreApplication a(argc, argv); // This is a first demo application of the SmtpClient for Qt project // Now we create a MimeMessage object. This is the email. MimeMessage message; EmailAddress sender("your_email_address@host.com", "Your Name"); message.setSender(sender); EmailAddress to("recipient@host.com", "Recipient's Name"); message.addRecipient(to); message.setSubject("SmtpClient for Qt - Demo"); // Now add some text to the email. // First we create a MimeText object. MimeText text; text.setText("Hi,\nThis is a simple email message.\n"); // Now add it to the mail message.addPart(&text); // Now we can send the mail SmtpClient smtp("smtp.gmail.com", 465, SmtpClient::SslConnection); smtp.connectToHost(); if (!smtp.waitForReadyConnected()) { qDebug() << "Failed to connect to host!"; return -1; } smtp.login("your_email_address@host.com", "your_password"); if (!smtp.waitForAuthenticated()) { qDebug() << "Failed to login!"; return -2; } smtp.sendMail(message); if (!smtp.waitForMailSent()) { qDebug() << "Failed to send mail!"; return -3; } smtp.quit(); } ``` 有关更多示例,请参阅 Wiki/Examples(https://github.com/bluetiger9/SmtpClient-for-Qt/wiki/Examples). ## 许可证 该项目(包括演示/示例在内的所有文件)根据 GNU LGPL 版本 2.1 获得许可。 版权所有 (c) 2014-2022 - Attila Tőkés**