summaryrefslogtreecommitdiff
path: root/src/message/sender.hpp
blob: d19e20987d788c4c5980010f67033fe16808a5f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <list>
#include <memory>

#include <curl/curl.h>

#include "managment/settings.hpp"
#include "managment/mail.hpp"

namespace smtp::message
{
	struct WriteThis
	{
		int counter;
	};

	class Sender
	{
	public:
		Sender( manage::Settings& settings_storage, manage::Mail const& mail_to );
		~Sender() = default;

		bool Send( std::string const& mail_from, std::string const& subject, std::string const& text );
	private:
		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;
		static size_t ReadCallBack( void* ptr, size_t size, size_t nmemb, void* userp );

		manage::Settings& mSettingsStorage;
		manage::Mail const& mMailTo;

		bool InitCurl( CURL* curl, WriteThis const& upload_ctx, std::string const& mail_from );
	};
}