<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/popd_util.erl</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -29,6 +29,7 @@
 
 	{server_pop_start, false},
 	{server_pop_port,110},
+	{server_pop_greeting,&quot;ErlMail POP server ready.&quot;},
 
 	{store_type_domain, mnesia_store},
 	{store_type_user, mnesia_store},
@@ -45,9 +46,7 @@
 	{antispam_default_action,continue},
 	{antispam_pre_deliver_action,[]},
 	{antispam_post_deliver_action,[]}
-	
-	
-	
+
 	]}
  ]
 }.</diff>
      <filename>ebin/erlmail.app</filename>
    </modified>
    <modified>
      <diff>@@ -18,9 +18,18 @@
 	}).
 
 -record(popd_fsm,{
-	socket     = [],
-	addr       = [],
-	options    = [],
-	line       = [],
-	buff       = &lt;&lt;&gt;&gt;
+	socket  = [],
+	addr    = [],
+	options = [],
+	line    = [],
+	state   = authorization,
+	user    = undefined,
+	pass    = undefined,
+	buff    = &lt;&lt;&gt;&gt;
+	}).
+
+-record(popd_cmd,{
+	line = [],
+	cmd  = [],
+	data = []
 	}).
\ No newline at end of file</diff>
      <filename>include/pop.hrl</filename>
    </modified>
    <modified>
      <diff>@@ -79,6 +79,8 @@ reload() -&gt;
 		imapd,imapd_listener,imapd_fsm,imapd_app,imapd_sup,imapd_util,imapd_cmd,imapd_util,imapd_ext,imapd_fetch,imapd_search,imapd_resp,
 		imap_parser,imap_scan,imapc,imapc_fsm,imapc_util,
 		mime,
+		popc,popc_fsm,
+		popd_app,popd_cmd,popd_fsm,popd_listener,popd_sum,popd_util,
 		smtpd_app,smtpd_sup,smtpd_fsm,smtpd_listener,smtpd_util,smtpd_cmd,smtpd_queue,
 		smtpc,smtpc_fsm,smtpc_util,
 		erlmail_test,erml_erlmail</diff>
      <filename>src/erlmail.erl</filename>
    </modified>
    <modified>
      <diff>@@ -45,6 +45,7 @@
 -export([split_email/1,combine_email/1,combine_email/2]).
 -export([create/4,join/1,remove/1,check/1,check/4]).
 -export([split_at/1,split_at/2,rsplit_at/1,rsplit_at/2,unquote/1]).
+-export([to_lower_atom/1]).
 -export([get_app_env/2]).
 
 
@@ -144,7 +145,9 @@ unquote(String) -&gt;
 
 
 
-
+to_lower_atom(Atom) when is_atom(Atom) -&gt; to_lower_atom(atom_to_list(Atom));
+to_lower_atom(String) when is_list(String) -&gt;
+	list_to_atom(string:to_lower(String)).
 
 
 </diff>
      <filename>src/erlmail_util.erl</filename>
    </modified>
    <modified>
      <diff>@@ -35,8 +35,36 @@
 %%%---------------------------------------------------------------------------------------
 -module(popd_cmd).
 -author('simpleenigma@gmail.com').
+-include(&quot;../include/pop.hrl&quot;).
 
--export([command/1]).
+-export([command/1,command/2]).
 
-command(State) -&gt;
-	ok.
\ No newline at end of file
+%%-------------------------------------------------------------------------
+%% @spec (State::popd_fsm()) -&gt; NewState::popd_fsm()
+%% @doc  Processes all POP commands and checks for extention processing
+%% @end
+%%-------------------------------------------------------------------------
+command(#popd_fsm{line = Line} = State) -&gt; 
+	Command = popd_util:parse(Line,State),
+	io:format(&quot;Command: ~p~n&quot;,[Command]),
+	command(Command,State).
+
+
+
+
+command(#popd_cmd{cmd = quit} = _Cmd,
+		#popd_fsm{state = authorization} = State) -&gt;
+	popd_util:send(ok,State),
+	gen_tcp:close(State#popd_fsm.socket),
+	gen_fsm:send_all_state_event(self(),stop),
+	State;
+command(#popd_cmd{cmd = quit} = _Cmd,
+		State) -&gt;
+	popd_util:send(ok,State),
+	% Clean up routines to delete messages
+	gen_tcp:close(State#popd_fsm.socket),
+	gen_fsm:send_all_state_event(self(),stop),
+	State;
+command(#popd_cmd{cmd = _Command} = _Cmd,State) -&gt;
+	popd_util:send(error,State),
+	State.
\ No newline at end of file</diff>
      <filename>src/popd_cmd.erl</filename>
    </modified>
    <modified>
      <diff>@@ -92,6 +92,8 @@ init([]) -&gt;
     inet:setopts(Socket, [{active, once}, binary]),
     {ok, {IP, _Port}} = inet:peername(Socket),
 	NextState = State#popd_fsm{socket=Socket, addr=IP},
+	Greeting = erlmail_util:get_app_env(server_pop_greeting,&quot;ready.&quot;),
+	popd_util:send([&quot;+OK &quot;,Greeting],NextState),
     {next_state, 'WAIT_FOR_DATA', NextState, ?TIMEOUT};
 'WAIT_FOR_SOCKET'(Other, State) -&gt;
     error_logger:error_msg(&quot;State: 'WAIT_FOR_SOCKET'. Unexpected message: ~p\n&quot;, [Other]),
@@ -103,11 +105,17 @@ init([]) -&gt;
 	NewBuff = &lt;&lt;Buff/binary,Data/binary&gt;&gt;,
 %	?D(NewBuff),
 	case end_of_cmd(NewBuff) of
-		0 -&gt; {next_state, 'WAIT_FOR_DATA', State#popd_fsm{buff = NewBuff}, ?TIMEOUT};
+		0 -&gt; 
+			case NewBuff of
+				?CRLF_BIN -&gt; 
+					NextState = popd_cmd:command(State#popd_fsm{line = [],buff = &lt;&lt;&gt;&gt;}),
+					{next_state, 'WAIT_FOR_DATA', NextState, ?TIMEOUT};
+				_ -&gt; {next_state, 'WAIT_FOR_DATA', State#popd_fsm{buff = NewBuff}, ?TIMEOUT}
+			end;
+			
 		Pos -&gt;
 			&lt;&lt;Line:Pos/binary,13,10,NextBuff/binary&gt;&gt; = NewBuff,
 			NextState = popd_cmd:command(State#popd_fsm{line = binary_to_list(Line),buff = NextBuff}),
-
 			{next_state, 'WAIT_FOR_DATA', NextState, ?TIMEOUT}
 	end;
     </diff>
      <filename>src/popd_fsm.erl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d39aeedd9d38964249bdd365b58e7fb128d3788a</id>
    </parent>
  </parents>
  <author>
    <name>simpleenigmainc</name>
    <email>simpleenigmainc@a0ed728d-bb3d-0410-838c-d777afece975</email>
  </author>
  <url>http://github.com/JackDanger/erlmail/commit/e04cd323fc9fcd92505e92f3f77a68dbfa0f2e26</url>
  <id>e04cd323fc9fcd92505e92f3f77a68dbfa0f2e26</id>
  <committed-date>2008-02-21T08:52:34-08:00</committed-date>
  <authored-date>2008-02-21T08:52:34-08:00</authored-date>
  <message>Work on POP server

git-svn-id: http://erlmail.googlecode.com/svn/trunk@148 a0ed728d-bb3d-0410-838c-d777afece975</message>
  <tree>f4586cb259233ccc10a5af55b966a16f8cc578c1</tree>
  <committer>
    <name>simpleenigmainc</name>
    <email>simpleenigmainc@a0ed728d-bb3d-0410-838c-d777afece975</email>
  </committer>
</commit>
