add support for sending emails in Http class

This commit is contained in:
2023-05-10 09:01:30 +02:00
parent cc2c008bfd
commit e822e13dc8
2 changed files with 147 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2022, Tomasz Sowa
* Copyright (c) 2010-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@ public:
method_patch,
method_delete,
method_options,
method_smtp,
};
Http();
@@ -265,6 +266,21 @@ public:
bool put(const std::wstring & url, const std::string & in, pt::WTextStream & out, bool clear_stream = true);
bool put(const wchar_t * url, pt::WTextStream & in, pt::WTextStream & out, bool clear_stream = true);
Http & add_recipient(const char * recipient);
Http & add_recipient(const std::string & recipient);
Http & add_recipient(const wchar_t * recipient);
Http & add_recipient(const std::wstring & recipient);
bool send_mail(const wchar_t * smtp_url, const wchar_t * from, const std::string & in, pt::WTextStream & out, bool clear_stream = true);
bool send_mail(const wchar_t * smtp_url, const wchar_t * from, pt::WTextStream & in, pt::WTextStream & out, bool clear_stream = true);
Http & set_username(const wchar_t * username);
Http & set_password(const wchar_t * password);
Http & set_username(const std::wstring & username);
Http & set_password(const std::wstring & password);
/*
* return the last http status
*/
@@ -281,6 +297,7 @@ private:
size_t read_function_index;
const std::string * read_function_input;
curl_slist * http_headers;
curl_slist * smtp_recipients;
pt::Space * additional_space_headers_to_send;
const char * additional_string_headers_to_send;
const wchar_t * additional_wstring_headers_to_send;
@@ -301,6 +318,9 @@ private:
const wchar_t * client_key;
std::string client_cert_utf8;
std::string client_key_utf8;
const wchar_t * smtp_from;
const wchar_t * username;
const wchar_t * password;
std::wstring temp_header;
std::string temp_header_ascii;