Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SENDMAIL_H
00030 #define SENDMAIL_H
00031
00032 #include <QtCore>
00033
00034 #include "QGpGuiToolsDLLExport.h"
00035
00036 class QTcpSocket;
00037
00038 namespace QGpGuiTools {
00039
00040 class QGPGUITOOLS_EXPORT SendMail : public QObject
00041 {
00042 Q_OBJECT
00043 public:
00044 SendMail(const QString &smtp, const QString &from, const QString &to,
00045 const QString &subject, const QString &body,
00046 const QStringList * files=0);
00047 ~SendMail();
00048 public slots:
00049 void send();
00050 private slots:
00051 void readyRead();
00052 void connected();
00053 void dataWritten(qint64 nbytes);
00054 signals:
00055 void dataProgressValue(int val);
00056 void dataProgressMaximum(int val);
00057 void status(const QString &);
00058 void finished(bool);
00059 private:
00060 QString encode(uchar * buf, int bufLen);
00061 void addAttachments();
00062 void cleanTmpDir(QDir& tmp);
00063 enum State {
00064 Init,
00065 Mail,
00066 Rcpt,
00067 Data,
00068 Body,
00069 Quit,
00070 Close
00071 };
00072
00073 QString _smtp;
00074 QString _message;
00075 QString _from;
00076 QString _to;
00077 QStringList _files;
00078
00079 QTcpSocket * _socket;
00080 QTextStream * _t;
00081 int _state;
00082 int _dataWritten;
00083 };
00084
00085 }
00086
00087 #endif // SENDMAIL_H