mail::Header::list — Create a list of headers.


#include <libmail/headers.H>

mail::Header::list headers;

    headers << mail::Header::encoded("Subject", "Hello", "iso-8859-1")
            << mail::header::addresslist("To")
                                        ("John", "")
                                        ("Tom", "")
            << mail::Header::mime("Content-Type", "text/plain")
                                 ("charset", "iso-8859-1");

std::cout << (std::string)headers;


This is a helper class for formatting a list of headers. Each header is specified, using the << operator, which can take any combination of mail::Header::addresslist(3x), mail::Header::encoded(3x), mail::Header::mime(3x), or mail::Header::plain(3x).


The << operator makes an internal copy of the header object. The original object may be destroyed after the operator returns.

The std::string operator formats all headers, and returns the set of E-mail headers as a single string. Long headers are folded accordingly.