Projet Bee-Honey't  1.0
BTS SN 2019
sender.h
Aller à la documentation de ce fichier.
1 /*
2  Copyright (c) 2011-2012 - Tőkés Attila
3  Copyright (C) 2015 Daniel Nicoletti <dantti12@gmail.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  See the LICENSE file for more details.
16 */
17 
18 #ifndef SIMPLEMAIL_SENDER_H
19 #define SIMPLEMAIL_SENDER_H
20 
21 #include <QObject>
22 #include <QtNetwork/QSslSocket>
23 
24 #include "mimemessage.h"
25 #include "smtpexports.h"
26 
27 namespace SimpleMail {
28 
29 class SenderPrivate;
30 class SMTP_EXPORT Sender : public QObject
31 {
32  Q_OBJECT
33  Q_DECLARE_PRIVATE(Sender)
34 public:
36  {
39  AuthLogin
40  };
41  Q_ENUM(AuthMethod)
42 
43  enum SmtpError
44  {
49  ServerError, // 4xx smtp error
50  ClientError // 5xx smtp error
51  };
52  Q_ENUM(SmtpError)
53 
55  {
58  TlsConnection // STARTTLS
59  };
60  Q_ENUM(ConnectionType)
61 
63  {
65  VerifyPeer
66  };
67  Q_ENUM(PeerVerificationType)
68 
69  explicit Sender(QObject *parent = 0);
70  Sender(const QString &host, int port, ConnectionType ct, QObject *parent = 0);
71  virtual ~Sender();
72 
76  QString host() const;
77 
81  void setHost(const QString &host);
82 
86  int port() const;
87 
91  void setPort(int port);
92 
97  QString name() const;
98 
103  void setName(const QString &name);
104 
108  ConnectionType connectionType() const;
109 
113  void setConnectionType(ConnectionType ct);
114 
118  QString user() const;
119 
123  void setUser(const QString &user);
124 
128  QString password() const;
129 
133  void setPassword(const QString &password);
134 
138  AuthMethod authMethod() const;
139 
143  void setAuthMethod(AuthMethod method);
144 
148  QByteArray responseText() const;
149 
153  int responseCode() const;
154 
158  int connectionTimeout() const;
159 
163  void setConnectionTimeout(int msec);
164 
168  int responseTimeout() const;
169 
173  void setResponseTimeout(int msec);
174 
178  int sendMessageTimeout() const;
179 
183  void setSendMessageTimeout(int msec);
184 
189  void ignoreSslErrors();
190 
196  void ignoreSslErrors(const QList<QSslError> &errors);
197 
202  void setPeerVerificationType(PeerVerificationType type);
203 
208  PeerVerificationType peerVerificationType();
209 
210  bool sendMail(MimeMessage &email);
211 
212  QString lastError() const;
213 
214  void quit();
215 
216 protected Q_SLOTS:
217  void socketStateChanged(QAbstractSocket::SocketState state);
218  void socketError(QAbstractSocket::SocketError error);
219  void socketReadyRead();
220 
221 Q_SIGNALS:
222  void smtpError(SmtpError e);
223  void sslErrors(const QList<QSslError> &sslErrorList);
224 
225 protected:
227 };
228 
229 }
230 
231 #endif // SIMPLEMAIL_SENDER_H
SenderPrivate * d_ptr
Definition: sender.h:226
Definition: sender.h:37
Definition: sender.h:56
Definition: sender_p.h:29
#define SMTP_EXPORT
Definition: smtpexports.h:7
ConnectionType
Definition: sender.h:54
Definition: sender.h:49
SmtpError
Definition: sender.h:43
Definition: sender.h:38
Definition: sender.h:64
AuthMethod
Definition: sender.h:35
Definition: sender.h:30
Definition: mimemessage.h:31
PeerVerificationType
Definition: sender.h:62
Definition: emailaddress.h:26
Definition: sender.h:57