SecureSMTPClientSession.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "Poco/Net/SecureSMTPClientSession.h"
  14. #include "Poco/Net/SecureStreamSocket.h"
  15. #include "Poco/Net/SSLManager.h"
  16. #include "Poco/Net/DialogSocket.h"
  17. namespace Poco {
  18. namespace Net {
  19. SecureSMTPClientSession::SecureSMTPClientSession(const StreamSocket& socket):
  20. SMTPClientSession(socket)
  21. {
  22. }
  23. SecureSMTPClientSession::SecureSMTPClientSession(const std::string& host, Poco::UInt16 port):
  24. SMTPClientSession(host, port),
  25. _host(host)
  26. {
  27. }
  28. SecureSMTPClientSession::~SecureSMTPClientSession()
  29. {
  30. }
  31. bool SecureSMTPClientSession::startTLS()
  32. {
  33. return startTLS(SSLManager::instance().defaultClientContext());
  34. }
  35. bool SecureSMTPClientSession::startTLS(Context::Ptr pContext)
  36. {
  37. int status = 0;
  38. std::string response;
  39. status = sendCommand("STARTTLS", response);
  40. if (!isPositiveCompletion(status)) return false;
  41. SecureStreamSocket sss(SecureStreamSocket::attach(socket(), _host, pContext));
  42. socket() = sss;
  43. return true;
  44. }
  45. } } // namespace Poco::Net