diff options
author | claiff <claiff@mail.ru> | 2022-09-23 17:31:40 +0300 |
---|---|---|
committer | claiff <claiff@mail.ru> | 2022-09-23 17:31:40 +0300 |
commit | 8d38861429c3544d10752fb0f6f9da436dee218f (patch) | |
tree | 666af3e4317fbe9f19c9895a6e6694e86ea7cef9 /src/message | |
parent | ddd298d7c467dcca5c057ed6807c2fea5176f9a3 (diff) | |
parent | d981f7230bc641614c590717e16ac694762d92ac (diff) | |
download | obmc-sila-smtp-8d38861429c3544d10752fb0f6f9da436dee218f.tar.xz |
Merge branch 'feature/add_auth'
Diffstat (limited to 'src/message')
-rw-r--r-- | src/message/sender.cpp | 13 | ||||
-rw-r--r-- | src/message/sender.hpp | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/message/sender.cpp b/src/message/sender.cpp index 85c5d5d..a7e3128 100644 --- a/src/message/sender.cpp +++ b/src/message/sender.cpp @@ -76,11 +76,18 @@ namespace smtp::message { return false; } - curl_easy_setopt( curl, CURLOPT_USERNAME, mSettingsStorage.GetUserName().c_str()); - curl_easy_setopt( curl, CURLOPT_PASSWORD, mSettingsStorage.GetPassword().c_str()); + + if( mSettingsStorage.IsNeedAuth()) + { + curl_easy_setopt( curl, CURLOPT_USERNAME, mSettingsStorage.GetUserName().c_str()); + curl_easy_setopt( curl, CURLOPT_PASSWORD, mSettingsStorage.GetPassword().c_str()); + } + curl_easy_setopt( curl, CURLOPT_URL, GetHostPortData().c_str()); - curl_easy_setopt( curl, CURLOPT_USE_SSL, ( long ) CURLUSESSL_ALL ); + mSettingsStorage.IsNeedSsl() ? curl_easy_setopt( curl, CURLOPT_USE_SSL, ( long ) CURLUSESSL_ALL ) : + curl_easy_setopt( curl, CURLOPT_USE_SSL, ( long ) CURLUSESSL_NONE ); + curl_easy_setopt( curl, CURLOPT_MAIL_FROM, mail_from.c_str()); curl_easy_setopt( curl, CURLOPT_READFUNCTION, ReadCallBack ); diff --git a/src/message/sender.hpp b/src/message/sender.hpp index ba5953e..3118319 100644 --- a/src/message/sender.hpp +++ b/src/message/sender.hpp @@ -22,6 +22,7 @@ namespace smtp::message bool Send( std::string const& mail_from, std::string const& subject, std::string const& text ); private: + bool InitCurl( CURL* curl, WriteThis const& upload_ctx, std::string const& mail_from ); void UpdateMailText( std::string const& mail_from, std::string const& subject, std::string const& textt ) const; void FillRecipients(CURL* curl, curl_slist* recipients ); std::string GetHostPortData() const; @@ -29,8 +30,6 @@ namespace smtp::message manage::Settings& mSettingsStorage; manage::Mail const& mMailTo; - - bool InitCurl( CURL* curl, WriteThis const& upload_ctx, std::string const& mail_from ); }; } |