1 | // |
---|---|
2 | // SecureSMTPClientSession.h |
3 | // |
4 | // Library: NetSSL_OpenSSL |
5 | // Package: Mail |
6 | // Module: SecureSMTPClientSession |
7 | // |
8 | // Copyright (c) 2010, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/Net/SecureSMTPClientSession.h" |
16 | #include "Poco/Net/SecureStreamSocket.h" |
17 | #include "Poco/Net/SSLManager.h" |
18 | #include "Poco/Net/DialogSocket.h" |
19 | |
20 | |
21 | namespace Poco { |
22 | namespace Net { |
23 | |
24 | |
25 | SecureSMTPClientSession::SecureSMTPClientSession(const StreamSocket& socket): |
26 | SMTPClientSession(socket) |
27 | { |
28 | } |
29 | |
30 | |
31 | SecureSMTPClientSession::SecureSMTPClientSession(const std::string& host, Poco::UInt16 port): |
32 | SMTPClientSession(host, port), |
33 | _host(host) |
34 | { |
35 | } |
36 | |
37 | |
38 | SecureSMTPClientSession::~SecureSMTPClientSession() |
39 | { |
40 | } |
41 | |
42 | |
43 | bool SecureSMTPClientSession::startTLS() |
44 | { |
45 | return startTLS(SSLManager::instance().defaultClientContext()); |
46 | } |
47 | |
48 | |
49 | bool SecureSMTPClientSession::startTLS(Context::Ptr pContext) |
50 | { |
51 | int status = 0; |
52 | std::string response; |
53 | |
54 | status = sendCommand("STARTTLS", response); |
55 | if (!isPositiveCompletion(status)) return false; |
56 | |
57 | SecureStreamSocket sss(SecureStreamSocket::attach(socket(), _host, pContext)); |
58 | socket() = sss; |
59 | |
60 | return true; |
61 | } |
62 | |
63 | |
64 | } } // namespace Poco::Net |
65 |