diff options
Diffstat (limited to 'src/message_sender.hpp')
-rw-r--r-- | src/message_sender.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/message_sender.hpp b/src/message_sender.hpp new file mode 100644 index 0000000..0728f0e --- /dev/null +++ b/src/message_sender.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include <list> +#include <memory> + +#include <curl/curl.h> + +#include "settings_storage.hpp" + +namespace smtp +{ + struct WriteThis + { + int counter; + }; + + class MessageSender + { + public: + MessageSender( SettingsStorage const& settings_storage ); + ~MessageSender() = default; + + bool Send( std::string const& mail_from, std::string const& mail_to, std::list<std::string> const& cc, + std::string const& subject, std::string const& text ); + private: + std::string GetText( std::string const& mail_from, std::string const& mail_to, std::list<std::string> const& cc, + std::string const& subject, std::string const& textt ) const; + void InitSenders( std::string const& mail_from, std::list<std::string> const& mail_to ); + void FillRecipients( CURL* curl, std::string const& mail_to, std::list<std::string> const& cc, curl_slist* recipients ); + std::string GetHostPortData() const; + void ProcessSending(const std::string &mail_from, const std::list<std::string> &mail_to, const std::string &subject, const std::string &text); + timeval GetNowTime() const noexcept; + bool IsTimeOut( timeval const& start_time ) const noexcept; + long GetTimeDiff( timeval const& left, timeval const& right ) const noexcept; + timeval GetTimeout() const; + int ProcessHandle( timeval& timeout ) const; + void ClearPtrs(); + static size_t ReadCallBack( void *ptr, size_t size, size_t nmemb, void *userp ); + +// CURL *curl; +// CURLM *mcurl; + struct WriteThis pooh; + struct curl_slist* recipients = NULL; + SettingsStorage const& mSettingsStorage; + }; +} + + |