2
* Kscd - A simple cd player for the KDE Project
4
* $Id: smtp.h,v 1.7 2001/03/11 15:33:54 dfoerste Exp $
6
* Copyright (c) 1997 Bernd Johannes wuebben@math.cornell.edu
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
/*int SMTPServerStatus[] = {
32
220, // greeting from server
33
221, // server acknolages goodbye
34
250, // command successful
35
354, // ready to recieve data
41
int SMTPClientStatus[] = {
42
50, // not logged in yet.
43
100, // logged in, got 220
44
150, // sent helo, got 250
45
200, // sent mail from, got 250
46
250, // sent rctp to, got 250
47
300, // data sent, got 354
48
350, // sent data/., got 250
49
400, // send quit, got 221
50
450, // finished, logged out
55
#define DEFAULT_SMTP_PORT 25
56
#define DEFAULT_SMTP_SERVER localhost
57
#define DEFAULT_SMTP_TIMEOUT 60
59
#define SMTP_READ_BUFFER_SIZE 256
61
class SMTP:public QObject
65
SMTP(char *serverhost = 0, unsigned short int port = 0, int timeout = DEFAULT_SMTP_TIMEOUT);
68
void setServerHost(const QString& serverhost);
69
void setPort(unsigned short int port);
70
void setTimeOut(int timeout);
72
bool isConnected(){return connected;};
73
bool isFinished(){return finished;};
74
QString getLastLine(){return lastLine;};
76
void setSenderAddress(const QString& sender);
77
void setSenderReplyTo(const QString& replyto);
78
void setRecipientAddress(const QString& recipient);
79
void setMessageSubject(const QString& subject);
80
void setMessageBody(const QString& message);
84
GREET = 220, // greeting from server
85
GOODBYE = 221, // server acknolages quit
86
SUCCESSFUL = 250, // command successful
87
READYDATA = 354, // server ready to recieve data
89
UNKNOWN = 550 // user unknown
93
INIT = 50, // not logged in yet
94
IN = 100, // logged in, got 220
95
READY = 150, // sent HELO, got 250
96
SENTFROM = 200, // sent MAIL FROM:, got 250
97
SENTTO = 250, // sent RCTP TO:, got 250
98
DATA = 300, // DATA sent, got 354
99
FINISHED = 350, // finished sending data, got 250
100
QUIT = 400, // sent QUIT, got 221
101
OUT = 450, // finished, logged out
102
CERROR = 500 // didn't finish, had error or connection drop
110
INTERACTTIMEOUT = 16,
111
UNKNOWNRESPONSE = 20,
117
void processLine(QString *line);
120
void openConnection();
122
void closeConnection();
124
void connectTimerTick();
125
void connectTimedOut();
126
void interactTimedOut();
128
void socketRead(KSocket *);
129
void socketClose(KSocket *);
132
void connectionClosed();
138
unsigned short int hostPort;
144
QString senderAddress;
145
QString senderReplyTo;
146
QString recipientAddress;
147
QString messageSubject;
150
SMTPClientStatus state;
151
SMTPClientStatus lastState;
152
SMTPServerStatus serverState;
159
QTimer interactTimer;
161
char readBuffer[SMTP_READ_BUFFER_SIZE];