#ifndef INCLUDED_MAILER_
#define INCLUDED_MAILER_

#include <iosfwd>
#include <string>
#include <vector>

#include "../common/common.h"

class Mailer: private Common
{
    std::string d_to;
    std::string d_cc;
    std::string d_attachment;
    std::string d_subject;

    public:
//        Mailer() = default;

        void setCC(std::string const &cc,
                   std::string const &ccAddresses);

        void noCC();

        std::string const &cc() const;

        void addTo(std::string const &address); // add address to 'To'      
                                                // addresses unless already 
                                                // there                    

        void setTo(std::string const &address);

        void setSubject(std::string const &subject);
        void attach(std::string const &what);

            // sends mail to addressee(s) (d_to) unless no-mail was specified
            // mail sent either also includes CC addresses or
            // sends the zip file (no CC addresses) to specified addresses
        void sendmail(std::string const &subject, std::string const &txt);

    private:
        void inspectAppend(std::string const &txt);
};

extern Mailer g_mailer;

inline void Mailer::noCC()
{
    d_cc.clear();
}

inline std::string const &Mailer::cc() const
{
    return d_cc;
}

inline void Mailer::attach(std::string const &what)
{
    d_attachment = what;
}

inline void Mailer::setSubject(std::string const &subject)
{
    d_subject = subject;
}

inline void Mailer::setTo(std::string const &to)
{
    d_to = to;
}

inline void Mailer::setCC(std::string const &cc,
                          std::string const &ccAddresses)
{
    d_cc =  cc + ' ' + ccAddresses;
}
        
#endif
