00001 #ifndef SMTPHANDLER_H
00002 #define SMTPHANDLER_H
00003
00004 #include <qobject.h>
00005 #include <qstring.h>
00006
00007 #include "configfile.h"
00008
00009 class QSocket;
00010
00011 class SmtpHandler : public QObject
00012 {
00013 Q_OBJECT
00014
00015 public:
00016 SmtpHandler(const QString &header, const QString &message, Account &account, const QString &to);
00017
00018 enum SmtpError {
00019 ErrConnectionRefused,
00020 ErrHostNotFound,
00021 ErrUnknownResponse,
00022 ErrAuthNotSupported
00023 };
00024
00025 public slots:
00026 void stop();
00027
00028 signals:
00029 void finished();
00030 void error(const QString &);
00031 void status(const QString &);
00032
00033 private slots:
00034 void readyRead();
00035 void hostFound();
00036 void connected();
00037 void deleteMe();
00038 void errorHandling(int);
00039
00040 private:
00041 void sendToSocket(const QString &text, bool log = true);
00042
00043 enum State { Ehlo, Auth, ReadAuth, Helo, Mail, Rcpt,
00044 Data, Body, Quit, Close };
00045
00046 QString _header, _message;
00047 Account _account;
00048 QString _to;
00049 QSocket *_socket;
00050 int _state;
00051 };
00052
00053 #endif
00054
00055