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
21namespace Poco {
22namespace Net {
23
24
25SecureSMTPClientSession::SecureSMTPClientSession(const StreamSocket& socket):
26 SMTPClientSession(socket)
27{
28}
29
30
31SecureSMTPClientSession::SecureSMTPClientSession(const std::string& host, Poco::UInt16 port):
32 SMTPClientSession(host, port)
33{
34}
35
36
37SecureSMTPClientSession::~SecureSMTPClientSession()
38{
39}
40
41
42bool SecureSMTPClientSession::startTLS()
43{
44 return startTLS(SSLManager::instance().defaultClientContext());
45}
46
47
48bool SecureSMTPClientSession::startTLS(Context::Ptr pContext)
49{
50 int status = 0;
51 std::string response;
52
53 status = sendCommand("STARTTLS", response);
54 if (!isPositiveCompletion(status)) return false;
55
56 SecureStreamSocket sss(SecureStreamSocket::attach(socket(), host(), pContext));
57 socket() = sss;
58
59 return true;
60}
61
62
63} } // namespace Poco::Net
64