• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • misc
  • ksendbugmail
smtp.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2000 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
3 Copyright (c) 2000 Stephan Kulow <coolo@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#ifndef SMTP_H
20#define SMTP_H
21
22#include <QtCore/QObject>
23#include <QtCore/QTimer>
24#include <QtNetwork/QTcpSocket>
25#include <ksocketfactory.h>
26
27/*int SMTPServerStatus[] = {
28 220, // greeting from server
29 221, // server acknolages goodbye
30 250, // command successful
31 354, // ready to receive data
32 501, // error
33 550, // user unknown
34 0 // null
35};
36
37int SMTPClientStatus[] = {
38 50, // not logged in yet.
39 100, // logged in, got 220
40 150, // sent helo, got 250
41 200, // sent mail from, got 250
42 250, // sent rctp to, got 250
43 300, // data sent, got 354
44 350, // sent data/., got 250
45 400, // send quit, got 221
46 450, // finished, logged out
47 0 // null
48};
49*/
50
51#define DEFAULT_SMTP_PORT 25
52#define DEFAULT_SMTP_SERVER localhost
53#define DEFAULT_SMTP_TIMEOUT 60
54
55#define SMTP_READ_BUFFER_SIZE 256
56
57class SMTP:public QObject
58{
59 Q_OBJECT
60public:
61 explicit SMTP(char *serverhost = 0, unsigned short int port = 0,
62 int timeout = DEFAULT_SMTP_TIMEOUT);
63 ~SMTP();
64
65 void setServerHost(const QString& serverhost);
66 void setPort(unsigned short int port);
67 void setTimeOut(int timeout);
68
69 bool isConnected(){return connected;}
70 bool isFinished(){return finished;}
71 QString getLastLine(){return lastLine;}
72
73 void setSenderAddress(const QString& sender);
74 void setRecipientAddress(const QString& recipient);
75 void setMessageSubject(const QString& subject);
76 void setMessageBody(const QString& message);
77 void setMessageHeader(const QString &header);
78
79 typedef enum {
80 None = 0, // null
81 Greet = 220, // greeting from server
82 Goodbye = 221, // server acknolages quit
83 Successful = 250, // command successful
84 ReadyData = 354, // server ready to receive data
85 Error = 501, // error
86 Unknown = 550 // user unknown
87 }SMTPServerStatus;
88
89 typedef enum {
90 Init = 50, // not logged in yet
91 In = 100, // logged in, got 220
92 Ready = 150, // sent HELO, got 250
93 SentFrom = 200, // sent MAIL FROM:, got 250
94 SentTo = 250, // sent RCTP TO:, got 250
95 Data = 300, // Data sent, got 354
96 Finished = 350, // finished sending data, got 250
97 Quit = 400, // sent Quit, got 221
98 Out = 450, // finished, logged out
99 CError = 500 // didn't finish, had error or connection drop
100 }SMTPClientStatus;
101
102 typedef enum {
103 NoError = 0,
104 ConnectError = 10,
105 NotConnected = 11,
106 ConnectTimeout = 15,
107 InteractTimeout = 16,
108 UnknownResponse = 20,
109 UnknownUser = 30,
110 Command = 40
111 }SMTPError;
112
113protected:
114 void processLine(QString *line);
115
116public Q_SLOTS:
117 void openConnection();
118 void sendMessage();
119 void closeConnection();
120
121 void connectTimerTick();
122 void connectTimedOut();
123 void interactTimedOut();
124
125 void socketReadyToRead();
126 void socketClosed();
127 void socketError(QAbstractSocket::SocketError);
128
129Q_SIGNALS:
130 void connectionClosed();
131 void messageSent();
132 void error(int);
133
134private:
135 QString serverHost;
136 unsigned short int hostPort;
137 int timeOut;
138
139 bool connected;
140 bool finished;
141
142 QString senderAddress;
143 QString recipientAddress;
144 QString messageSubject;
145 QString messageBody, messageHeader;
146
147 SMTPClientStatus state;
148 SMTPClientStatus lastState;
149 SMTPServerStatus serverState;
150
151 QString domainName;
152
153 QTcpSocket *sock;
154 QTimer connectTimer;
155 QTimer timeOutTimer;
156 QTimer interactTimer;
157
158 char readBuffer[SMTP_READ_BUFFER_SIZE];
159 QString lineBuffer;
160 QString lastLine;
161 QString writeString;
162};
163#endif
QObject
QTcpSocket
SMTP
Definition: smtp.h:58
SMTP::socketError
void socketError(QAbstractSocket::SocketError)
Definition: smtp.cpp:234
SMTP::setMessageSubject
void setMessageSubject(const QString &subject)
Definition: smtp.cpp:118
SMTP::connectionClosed
void connectionClosed()
SMTP::setMessageBody
void setMessageBody(const QString &message)
Definition: smtp.cpp:123
SMTP::setSenderAddress
void setSenderAddress(const QString &sender)
Definition: smtp.cpp:89
SMTP::socketClosed
void socketClosed()
Definition: smtp.cpp:242
SMTP::socketReadyToRead
void socketReadyToRead()
Definition: smtp.cpp:207
SMTP::setTimeOut
void setTimeOut(int timeout)
Definition: smtp.cpp:84
SMTP::sendMessage
void sendMessage()
Definition: smtp.cpp:145
SMTP::isFinished
bool isFinished()
Definition: smtp.h:70
SMTP::error
void error(int)
SMTP::interactTimedOut
void interactTimedOut()
Definition: smtp.cpp:198
SMTP::isConnected
bool isConnected()
Definition: smtp.h:69
SMTP::setServerHost
void setServerHost(const QString &serverhost)
Definition: smtp.cpp:74
SMTP::SMTPServerStatus
SMTPServerStatus
Definition: smtp.h:79
SMTP::Successful
@ Successful
Definition: smtp.h:83
SMTP::None
@ None
Definition: smtp.h:80
SMTP::ReadyData
@ ReadyData
Definition: smtp.h:84
SMTP::Greet
@ Greet
Definition: smtp.h:81
SMTP::Unknown
@ Unknown
Definition: smtp.h:86
SMTP::Error
@ Error
Definition: smtp.h:85
SMTP::Goodbye
@ Goodbye
Definition: smtp.h:82
SMTP::~SMTP
~SMTP()
Definition: smtp.cpp:66
SMTP::connectTimedOut
void connectTimedOut()
Definition: smtp.cpp:189
SMTP::setRecipientAddress
void setRecipientAddress(const QString &recipient)
Definition: smtp.cpp:113
SMTP::connectTimerTick
void connectTimerTick()
Definition: smtp.cpp:163
SMTP::openConnection
void openConnection()
Definition: smtp.cpp:133
SMTP::processLine
void processLine(QString *line)
Definition: smtp.cpp:253
SMTP::SMTPError
SMTPError
Definition: smtp.h:102
SMTP::InteractTimeout
@ InteractTimeout
Definition: smtp.h:107
SMTP::Command
@ Command
Definition: smtp.h:110
SMTP::UnknownResponse
@ UnknownResponse
Definition: smtp.h:108
SMTP::NotConnected
@ NotConnected
Definition: smtp.h:105
SMTP::ConnectError
@ ConnectError
Definition: smtp.h:104
SMTP::ConnectTimeout
@ ConnectTimeout
Definition: smtp.h:106
SMTP::NoError
@ NoError
Definition: smtp.h:103
SMTP::UnknownUser
@ UnknownUser
Definition: smtp.h:109
SMTP::messageSent
void messageSent()
SMTP::getLastLine
QString getLastLine()
Definition: smtp.h:71
SMTP::setMessageHeader
void setMessageHeader(const QString &header)
Definition: smtp.cpp:128
SMTP::setPort
void setPort(unsigned short int port)
Definition: smtp.cpp:79
SMTP::SMTPClientStatus
SMTPClientStatus
Definition: smtp.h:89
SMTP::SentFrom
@ SentFrom
Definition: smtp.h:93
SMTP::Init
@ Init
Definition: smtp.h:90
SMTP::SentTo
@ SentTo
Definition: smtp.h:94
SMTP::Data
@ Data
Definition: smtp.h:95
SMTP::Quit
@ Quit
Definition: smtp.h:97
SMTP::Finished
@ Finished
Definition: smtp.h:96
SMTP::Ready
@ Ready
Definition: smtp.h:92
SMTP::CError
@ CError
Definition: smtp.h:99
SMTP::Out
@ Out
Definition: smtp.h:98
SMTP::In
@ In
Definition: smtp.h:91
SMTP::closeConnection
void closeConnection()
Definition: smtp.cpp:140
timeout
int timeout
ksocketfactory.h
DEFAULT_SMTP_TIMEOUT
#define DEFAULT_SMTP_TIMEOUT
Definition: smtp.h:53
SMTP_READ_BUFFER_SIZE
#define SMTP_READ_BUFFER_SIZE
Definition: smtp.h:55
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal