qt简单的邮件发送客户端



#include "smtpclient.h" #include <QtNetwork/QTcpSocket> #include <QTextCodec> #include <QTextStream> #include <QDataStream> #include <QFile> #include <QTimer> #include <QDebug> enum SMTPCMD{SMTP_EHLO = 0 , SMTP_AUTHLOGIN , SMTP_MAIL , SMTP_RCPT , SMTP_DATA , SMTP_QUIT}; struct SmtpClientData { SmtpClientData() : hostName("") , hostPort(0) , userName("") , userPassword("") , sender("") , receiver("") , subject("") , content("") , attachments("") , socket(0) , stream(0) , totalSize(0) , sentSize(1) { } QString hostName; // smtp.hikvision.com.cn unsigned int hostPort; // 25 as usual QString userName; // [email protected] QString userPassword; // test QString sender; // from QString receiver; // to QString subject; // abstract title QString content; // rich text QStringList attachments;// paths of attachments QTcpSocket *socket; // smtp socket QTextStream *stream; // text-stream for socket qint64 totalSize; // total size of mail containing text and attachments qint64 sentSize; // size already sent };












