In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize Qt mail sending tool". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "how to realize Qt mail sending tool" together.
I. Foreword
Main functions:
Hold mainstream mailbox such as 163 mailbox QQ mailbox sent.
Support rich text sending, you can send text with HTML format.
Support multiple attachments, attachments can be pictures.
void EmailThread::run(){ while (! stopped) { int count = contents.count(); if (count > 0) { mutex.lock(); QString content = contents.takeFirst(); QString fileName = fileNames.takeFirst(); mutex.unlock(); QString result; QStringList list = sendEmailAddr.split("@"); QString tempSMTP = list.at(1).split(". ").at(0); int tempPort = 25; //QQ mailbox port number is 465, SSL protocol must be enabled. if (tempSMTP.toUpper() == "QQ") { tempPort = 465; } SmtpClient smtp(QString("smtp.% 1.com").arg(tempSMTP), tempPort, tempPort == 25 ? SmtpClient::TcpConnection : SmtpClient::SslConnection); smtp.setUser(sendEmailAddr); smtp.setPassword(sendEmailPwd); //Build a mail subject that includes sender and recipient attachments, etc. MimeMessage message; message.setSender(new EmailAddress(sendEmailAddr)); //Add recipients one by one QStringList receiver = receiveEmailAddr.split(';'); for (int i = 0; i
< receiver.size(); i++) { message.addRecipient(new EmailAddress(receiver.at(i))); } //构建邮件标题 message.setSubject(emialTitle); //构建邮件正文 MimeHtml text; text.setHtml(content); message.addPart(&text); //构建附件-报警图像 if (fileName.length() >0) { QStringList attas = fileName.split(";"); foreach (QString tempAtta, attas) { QFile *file = new QFile(tempAtta); if (file->exists()) { message.addPart(new MimeAttachment(file)); } } } if (! smtp.connectToHost()) { result = "Mail server connection failed"; } else { if (! smtp.login()) { result = "Mail user login failed"; } else { if (! smtp.sendMail(message)) { result = "Message sending failed"; } else { result = "Email sent successfully"; } } } smtp.quit(); if (! result.isEmpty()) { emit receiveEmailResult(result); } msleep(1000); } msleep(100); } stopped = false;} 3. Effect diagram
Thank you for reading, the above is "Qt mail sending tool how to achieve" the content, after the study of this article, I believe we have a deeper understanding of how to achieve this problem Qt mail sending tool, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.