#ifndef __SMTPSession_h__
# define __SMTPSession_h__

# include "TCPSession.h"
# include "TCPServer.h"
# include "MString.h"

# define CRLF "\r\n"

namespace mail {

   enum State {CONNECT, READY, READYX, MAIL, RCPT, DATA, SENT};
   enum AuthState {USER_UNKNOWN, USER_QUERY, USER_SECRET_QUERY, USER_KNOWN};
   enum Mode {WAIT_FOR_DATA, RECEIVE_DATA};

   class SMTPSession : public core::TCPSession {

    public:
      SMTPSession(core::EPoll &ePoll, core::TCPServer &server);

      void onConnected() override;

      coreutils::MString clientDomainName;
      coreutils::MString userName;
      coreutils::MString password;
      coreutils::MString mailData;
      State state = CONNECT;
      AuthState authState = USER_UNKNOWN;
      Mode mode = WAIT_FOR_DATA;
      bool relay = true;
      coreutils::MString from;
      std::vector<coreutils::MString> recipientList;

   };

}

#endif
