1. Preface
Mail forwarding function and SMS alert function are basically the same, they are triggered after judging the alert, which may be slightly different. Mail forwarding needs to rely on the Internet, and can send a large amount of data without the limitation of 60 characters of SMS (of course, SMS can split multiple sending, but it costs money to control as much information as possible in one message contentIn the case that the user can understand the content of the text message, mail forwarding also encapsulates a kind of SendEmailThread, and SMS forwarding peer, which are sent by threads. In this system, when organizing the content of the message, the alarm information is intentionally sent out in a tabular form, so that the received alarm message updates are intuitive and clear, and the interval for sending the alarm can be adjusted0 minutes means real-time sending, once the alarm is triggered, immediately send the alarm. It is not necessary to send the alarm in real time. You can adjust the alarm to half a day or once a day, so that the table contents have more lines and look more comfortable, instead of jumping to receive an alarm message, jumping to receive another alarm message, which is very annoying.
This system not only supports alarm trigger to send mail, but also supports some specific functions such as sending alarm to organize mail regularly to the responsible mailbox. The responsible person's mailbox supports more than one. Of course, there are leaders in addition to the responsible person. Sometimes the leaders want to see the specific running reports even when they are full and idle, or in the phase of testing hardware, hardware BUG is often wrong.Reporting, you can send the corresponding hardware engineer to see the alarm rules and corresponding trigger values for himself.
Mail Sending Tool Open Source: https://gitee.com/feiyangqingyun/QWidgetDemo https://github.com/feiyangqingyun/QWidgetDemo File name: email
Experience address: https://gitee.com/feiyangqingyun/QWidgetExe https://github.com/feiyangqingyun/QWidgetExe File name: bin_sams.zip
2. Functional features
- Collect data port, support serial port + network port, support free serial port + baud rate, network support free set IP address + communication port, each port supports collection cycle, default 1 second address, support set communication timeout, default 3 times, support maximum reconnection time, for re-reading offline devices.
- Controller information, the ability to add a controller name, select a controller address + controller model, and set the number of detectors under the controller.
- Detector information, can add bit number, freely select the type of detector, gas type, gas symbol, high report value, low report value, buffer value, zero value, whether enabled, alarm sound, background map, storage period, numeric conversion of decimal places, alarm delay time, alarm type (HH,LL,HL), etc.
- Controller model + detector model + gas type + gas symbol, can be freely configured.
- Maps support import and delete, and all detectors are free to drag and save map locations.
- Port information + Controller information + Detector information, support import export + export to excel + print.
- Run records + alarm records + user records, support multi-conditional combination queries, such as time period + controller + detector, all records support export to excel + print.
- Records exported to excel support all forms file versions such as excel+wps and do not rely on software such as excel.
- Data within a specified time range can be deleted, early data can be automatically cleaned up, and the maximum number of records can be saved.
- Supports alarm text message forwarding, supports multiple receiving mobile phone numbers, and can set the sending interval, such as sending all alarm messages instantly or once in 6 hours, the text message content is too long, and automatically splits multiple text messages.
- Supports alarm mail forwarding, supports multiple receiving mailboxes, and can set sending intervals, such as sending all alarm messages instantly or once in six hours, and supports attachment sending.
- High report color + low report color + normal color + 0 value color + curve background + curve color, etc., can be chosen freely.
- The Chinese title, English title, logo path and copyright of the software can be set freely.
- Provides switch settings for on-off operation + alarm sound + automatic logon + password remembering, etc.
- The alarm sound sets the number of playback times and the interface provides 17 skin file choices.
- Supports cloud data synchronization by setting up information about cloud databases, such as database name, user name + password, etc.
- Supports network forwarding and network reception. After network reception is turned on, the software receives data from udp for analysis.Network forwarding supports multiple target IP, which enables locally collected software to freely transfer data to the client and view detector data at any time.
- Automatically remember the user's last remaining interface + other information and apply it automatically after restart.
- The alarm automatically switches to the corresponding map, and the detector button flashes.
- Double-click the detector icon for control.
- Support user rights management, administrator + operator two categories, user login + user exit, can remember password and automatic login, more than three error prompts and close the program.
- Supports four monitoring modes, device panel monitoring + map monitoring + tabular data monitoring + curve data monitoring, can switch freely, and four simultaneous applications.
- Supports alarm relay linkage, a bit number can link multiple modules and relay numbers across the serial port, supporting many-to-many.
- Local data stores support sqlite+mysql and remote data synchronization to cloud databases.Automatic reconnection.
- Data collected by local devices is uploaded to the cloud in real time for extraction by other means such as mobile APP or web.
- Two kinds of data sources are supported, one is serial port and network to collect device data through protocol, the other is database collection.The database collection mode can be used as a common system.
- The built-in device emulation tool supports 16 device data emulation as well as database data emulation to test data when there is no device.
- The default communication protocol uses the modbus protocol, and later adds the support of Internet of Things protocols such as mqtt to make a universal system.
- Supports all windows operating systems + linux operating systems and other operating systems.
3. Effect Charts
4. Core Code
#include "sendemailthread.h" #include "sendemail/smtpmime.h" #pragma execution_character_set("utf-8") #define TIMEMS qPrintable(QTime::currentTime().toString("hh:mm:ss zzz")) QScopedPointer<SendEmailThread> SendEmailThread::self; SendEmailThread *SendEmailThread::Instance() { if (self.isNull()) { static QMutex mutex; QMutexLocker locker(&mutex); if (self.isNull()) { self.reset(new SendEmailThread); } } return self.data(); } SendEmailThread::SendEmailThread(QObject *parent) : QThread(parent) { stopped = false; emialTitle = "Mail Title"; sendEmailAddr = "feiyangqingyun@126.com"; sendEmailPwd = "123456789"; receiveEmailAddr = "feiyangqingyun@163.com;517216493@qq.com"; contents.clear(); fileNames.clear(); } SendEmailThread::~SendEmailThread() { this->stop(); this->wait(1000); } void SendEmailThread::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); //Construct the subject of the message, including the sender's and recipient's 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))); } //Build Mail Title message.setSubject(emialTitle); //Build Mail Body MimeHtml text; text.setHtml(content); message.addPart(&text); //Build attachment-alarm image 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 failure"; } else { if (!smtp.sendMail(message)) { result = "Mail sending failed"; } else { result = "Mail sent successfully"; } } } smtp.quit(); if (!result.isEmpty()) { emit receiveEmailResult(result); } msleep(1000); } msleep(100); } stopped = false; } void SendEmailThread::stop() { stopped = true; } void SendEmailThread::setEmialTitle(const QString &emailTitle) { this->emialTitle = emailTitle; } void SendEmailThread::setSendEmailAddr(const QString &sendEmailAddr) { this->sendEmailAddr = sendEmailAddr; } void SendEmailThread::setSendEmailPwd(const QString &sendEmailPwd) { this->sendEmailPwd = sendEmailPwd; } void SendEmailThread::setReceiveEmailAddr(const QString &receiveEmailAddr) { this->receiveEmailAddr = receiveEmailAddr; } void SendEmailThread::append(const QString &content, const QString &fileName) { mutex.lock(); contents.append(content); fileNames.append(fileName); mutex.unlock(); }