xref: /haiku/src/add-ons/mail_daemon/outbound_protocols/smtp/SMTP.h (revision a5a3b2d9a3d95cbae71eaf371708c73a1780ac0d)
1 /*
2  * Copyright 2007-2015, 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 <MailFilter.h>
15 #include <MailProtocol.h>
16 #include <MailSettings.h>
17 
18 #ifdef USE_SSL
19 #	include <openssl/ssl.h>
20 #	include <openssl/rand.h>
21 #endif
22 
23 
24 class SMTPProtocol : public BOutboundMailProtocol {
25 public:
26 								SMTPProtocol(
27 									const BMailAccountSettings& settings);
28 	virtual						~SMTPProtocol();
29 
30 protected:
31 			status_t			Connect();
32 			void				Disconnect();
33 
34 	virtual	status_t			HandleSendMessages(const BMessage& message,
35 									off_t totalBytes);
36 
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 
46 private:
47 			status_t			_SendMessage(const entry_ref& ref);
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