This is an implementation of a POP3 client. It implements a sufficient subset of RFC-1939 to be useful in the context of the Epop package. With this module it is possible to do: stat, scan, retrieve, delete, reset and quit, as well as the commands uidl and top. It is possible to specify that the APOP authentication scheme should be used.
This module also supports the notification extension which is reflected with the functions: accept/2, accept/3 and notify/3.
Important information about the operations are written to the error_handler module, which in the context of Epop will lead to a log-file
connect(UserAddr, Passwd) -> Result
connect(UserAddr, Passwd, Options) -> Result
UserAddr = string()Passwd = string()Options = list( {port,Port} | {snoop,Bool} | apop )Port = integer()Bool = true | falseResult = {ok,SessionKey} | {error,Reason}SessionKey = opaque()Reason = atom()Setup the connection to the POP3 server specified in UserAddr. This argument should consist of a string: PopId@PopHost , e.g ''pop1234@my.mail.provider''
The Passwd argument specifies the secret password tp be used. If APOP hasn't been specified among the Options, then this password will be sent in clear text. However, if APOP is specified, then this password is used in the computation of the APOP digest message as described in RFC-1939.
accept(Sock, Passwd) -> Result
accept(Sock, Passwd, Options) -> Result
Sock = a listen socketPasswd = string()Options = list( {snoop,Bool} | apop )Result = {ok,SessionKey} | {error,Reason}SessionKey = opaque()Reason = atom()This function is used when we want to be able to accept a notification from a POP3 server.
The Passwd argument specifies the secret password tp be used. If APOP hasn't been specified among the Options, then this password will be sent in clear text. However, if APOP is specified, then this password is used in the computation of the APOP digest message as described in RFC-1939.
SessionKey = opaque()Result = {ok,Answer} | {error,Reason}Reason = atom()Answer = tuple(NumOfMsgs, TotalSize)NumOfMsgs = integer()TotalSize = integer()Send the STAT command to the POP3 server of this session. Returns a tuple with the number of stored messages and the total size of the maildrop in bytes.
scan(SessionKey) -> MultiResult
scan(SessionKey, MsgNumber) -> SingleResult
SessionKey = opaque()SingleResult = {ok,SingleAnswer} | {error,Reason}MultiResult = {ok,MultiAnswer} | {error,Reason}Reason = atom()SingleAnswer = tuple(MsgNumber, MsgSize)MultiAnswer = list(SingleAnswer)MsgNumber = integer()MsgSize = integer()Send the SCAN command to the POP3 server of this session. Either we can specifiy a certain message number, in which case we will get back a tuple with the size of the specified message, or we can omit to specify a certain number which will return a list of tuples representing all messages stored at the server. The above of course assumes a successful operation, otherwise we will get an error reason instead.
![]() |
Messages marked as deleted are not listed. |
uidl(SessionKey) -> MultiResult
uidl(SessionKey, MsgNumber) -> SingleResult
SessionKey = opaque()SingleResult = {ok,SingleAnswer} | {error,Reason}MultiResult = {ok,MultiAnswer} | {error,Reason}Reason = atom()SingleAnswer = tuple(MsgNumber, MsgId)MultiAnswer = list(SingleAnswer)MsgNumber = integer()MsgId = a unique-id, see RFC-1939, p.11Send the UIDL command to the POP3 server of this session. Either we can specifiy a certain message number, in which case we will get back a tuple with the unique identification of the specified message, or we can omit to specify a certain number which will return a list of tuples representing all messages stored at the server. The above of course assumes a successful operation, otherwise we will get an error reason instead.
![]() |
Messages marked as deleted are not listed. |
retrieve(SessionKey, MsgNumber) -> Result
SessionKey = opaque()MsgNumber = integer()Result = {ok,Message} | {error,Reason}Message = string()Reason = atom()Send the RETR command to the POP3 server of this session. Return the specified message or an error reason.
top(SessionKey, MsgNumber, Lines) -> Result
SessionKey = opaque()MsgNumber = integer()Lines = integer()Result = {ok,Message} | {error,Reason}Message = string()Reason = atom()Send the TOP command to the POP3 server of this session. If the number of lines in the message is lesser than what is specified in the Lines argument, the whole message is returned. Otherwise, only the first number of Lines in the message will be returned. A third alternative is to return an error reason.
delete(SessionKey, MsgNumber) -> Result
SessionKey = opaque()MsgNumber = integer()Result = ok | {error,Reason}Message = string()Reason = atom()Send the DELE command to the POP3 server of this session. Return ok at success or an error reason.
![]() |
The message won't actually be deleted until the QUIT command terminates the session. The deletion of messages can be undone by using the reset function. |
SessionKey = opaque()Result = ok | {error,Reason}Reason = atom()Send the RSET command to the POP3 server of this session. Order the POP3 server to unmark all messages currently marked for deletion.
If the notification extension is turned on at the POP3 server, it will also cause any order for notification to be cleared.
SessionKey = opaque()Result = ok | {error,Reason}Reason = atom()Send the QUIT command to the POP3 server of this session. Orders the POP3 server to terminate the session and closes the connection to the POP3 server.
All messages earlier marked for deletion will be deleted by the server.
notify(SessionKey, HostName, PortNo) -> Result
SessionKey = opaque()HostName = string()PortNo = integer()Result = ok | {error,Reason}Reason = atom()Send the NTFY command to the POP3 server of this session. Return ok at success or an error reason.
![]() |
The order for notification will not be activated until the QUIT command has terminated the session. The order for notification can be undone by using the reset function. |
Check out RFC-1939.
The notification extension made to POP3 is described in RFC-pop3-notification.txt.