1/*
2 * Copyright 2007-2011, Haiku Inc. All Rights Reserved.
3 * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
4 * Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
5 *
6 * Distributed under the terms of the MIT License.
7 */
8#ifndef SMTP_H
9#define SMTP_H
10
11
12#include <String.h>
13
14#include <MailAddon.h>
15#include <MailProtocol.h>
16#include <MailSettings.h>
17
18
19#ifdef USE_SSL
20#	include <openssl/ssl.h>
21#	include <openssl/rand.h>
22#endif
23
24
25class SMTPProtocol : public OutboundProtocol {
26public:
27								SMTPProtocol(BMailAccountSettings* settings);
28								~SMTPProtocol();
29
30			status_t			Connect();
31			void				Disconnect();
32
33			status_t			SendMessages(const std::vector<entry_ref>&
34									mails, size_t totalBytes);
35
36			//----Perfectly good holdovers from the old days
37			status_t			Open(const char *server, int port, bool esmtp);
38			void				Close();
39			status_t			Login(const char *uid, const char *password);
40			status_t			Send(const char *to, const char *from,
41									BPositionIO *message);
42
43			int32				ReceiveResponse(BString &line);
44			status_t			SendCommand(const char *cmd);
45
46private:
47			status_t			_SendMessage(const entry_ref& mail);
48			status_t			_POP3Authentication();
49
50			int					fSocket;
51			BString				fLog;
52			BMessage			fSettingsMessage;
53			int32				fAuthType;
54
55#ifdef USE_SSL
56		SSL_CTX *ctx;
57		SSL *ssl;
58		BIO *sbio;
59
60		bool use_ssl;
61		bool use_STARTTLS;
62#endif
63
64			status_t			fStatus;
65			BString				fServerName;	// required for DIGEST-MD5
66};
67
68
69#endif // SMTP_H
70