libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::curl Class Reference

#include <curl.hpp>

Inherits boost::noncopyable.

Classes

class  email_recipients
 

Public Types

using recipients_t = std::list< std::string >
 
using failures_t = std::vector< std::tuple< std::string, std::string > >
 

Public Member Functions

 curl (std::string const &smtp_url, unsigned short port, std::string const &username, std::string const &password, bool enable_logging, bool enable_ssl_verification=false) noexcept(false)
 
 ~curl () noexcept(true)
 
void from (std::string const &from) noexcept(true)
 
failures_t send (std::string const &subject, std::string const &body, recipients_t const &recipients) noexcept(false)
 

Friends

std::ostream & operator<< (std::ostream &os, curl const &c) noexcept(false)
 

Detailed Description

Curl tutorial.

Definition at line 38 of file curl.hpp.

Member Typedef Documentation

◆ failures_t

using jmmcg::LIBJMMCG_VER_NAMESPACE::curl::failures_t = std::vector<std::tuple<std::string, std::string> >

Definition at line 41 of file curl.hpp.

◆ recipients_t

using jmmcg::LIBJMMCG_VER_NAMESPACE::curl::recipients_t = std::list<std::string>

Definition at line 40 of file curl.hpp.

Constructor & Destructor Documentation

◆ curl()

jmmcg::LIBJMMCG_VER_NAMESPACE::curl::curl ( std::string const &  smtp_url,
unsigned short  port,
std::string const &  username,
std::string const &  password,
bool  enable_logging,
bool  enable_ssl_verification = false 
)
noexcept
Parameters
smtp_urlThe hostname:port to which the email should be sent.

Definition at line 70 of file curl.cpp.

◆ ~curl()

jmmcg::LIBJMMCG_VER_NAMESPACE::curl::~curl ( )
noexcept

Definition at line 93 of file curl.cpp.

Member Function Documentation

◆ from()

void jmmcg::LIBJMMCG_VER_NAMESPACE::curl::from ( std::string const &  from)
noexcept

Note that this option isn't strictly required, omitting it will result in libcurl sending the MAIL FROM command with empty sender data. All autoresponses should have an empty reverse-path, and should be directed to the address in the reverse-path which triggered them. Otherwise, they could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.

Definition at line 109 of file curl.cpp.

◆ send()

curl::failures_t jmmcg::LIBJMMCG_VER_NAMESPACE::curl::send ( std::string const &  subject,
std::string const &  body,
recipients_t const &  recipients 
)
noexcept

We're using a callback function to specify the payload (the headers and body of the message). You could just use the CURLOPT_READDATA option to specify a FILE pointer to read from.

Definition at line 134 of file curl.cpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
curl const &  c 
)
friend

Definition at line 76 of file curl.hpp.


The documentation for this class was generated from the following files: