#include "__SMTP_MAIL.h"

namespace mail {

   int __SMTP_MAIL::processCommand(coreutils::ZString &request, SMTPSession &session, SMTPServer &server) {

      if(request[1].ifNext("FROM:")) {
	 request[1].skipWhitespace();
	 if(request[1].ifNext("<")) {
	    session.from = request[1].getTokenExclude(">");
	    if(session.authState = USER_KNOWN) {
	       session.out << "250 OK" << CRLF;
	       session.recipientList.clear();
	       session.state = MAIL;
	    }
	 } else
	   session.out << "550 Usage: MAIL FROM:<email-address>" << CRLF;
      } else
	session.out << "550 Usage: MAIL FROM:<email-address>" << CRLF;
      return 1;
   }

//   std::string domainOnly(std::string email) {
//      coreutils::ZString split(email);
//      split.split("@");
//      return split[1].str();
//   }

}

