https://github.com/moteus/lua-pop3
POP3 client library for Lua
https://github.com/moteus/lua-pop3
email lua pop3 pop3-client
Last synced: 7 months ago
JSON representation
POP3 client library for Lua
- Host: GitHub
- URL: https://github.com/moteus/lua-pop3
- Owner: moteus
- License: mit
- Created: 2012-06-27T15:16:33.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-05-23T11:51:47.000Z (over 8 years ago)
- Last Synced: 2025-03-28T21:37:45.742Z (10 months ago)
- Topics: email, lua, pop3, pop3-client
- Language: Lua
- Size: 629 KB
- Stars: 15
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-lua - lua-pop3 - POP3 client library for Lua (Email)
README
lua-pop3
============
## Build status ##
[](LICENCE.txt)
[](https://travis-ci.org/moteus/lua-pop3)
[](https://coveralls.io/r/moteus/lua-pop3)
POP3 client library for Lua 5.1 / 5.2 / 5.3
## Dependences ##
* [LuaSocket](http://www.impa.br/~diego/software/luasocket)
### Decode text headers/content ###
* [iconv](http://ittner.github.com/lua-iconv)
### Parse from/to/reply headers ###
* [lpeg](http://www.inf.puc-rio.br/~roberto/lpeg)
### MD5 modules ###
* [lmd5](http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmd5)
* or [md5](http://www.keplerproject.org/md5/index.html)
### APOP auth ###
* [lua-crypto](http://luacrypto.luaforge.net)
* or [openssl](https://github.com/zhaozg/lua-openssl)
* or one of MD5 modules.
### CRAM MD5 auth ###
* [lua-crypto](http://luacrypto.luaforge.net)
* or [openssl](https://github.com/zhaozg/lua-openssl)
* or one of MD5 modules and bit library.
### Detect current codepage on Windows ###
* [alien](http://mascarenhas.github.io/alien)
* or [FFI](https://github.com/jmckaskill/luaffi)
## Usage ##
```lua
local pop3 = require "pop3"
local some_mail = {
host = os.getenv("LUA_MAIL_HOST") or '127.0.0.1';
username = os.getenv("LUA_MAIL_USER") or 'me@host.local';
password = os.getenv("LUA_MAIL_PASS") or 'mypassword';
}
local function print_msg(msg, indent)
indent = indent or ''
print(indent .. "----------------------------------------------")
print(indent .. "ID: ", msg:id())
print(indent .. "subject: ", msg:subject())
print(indent .. "to: ", msg:to())
print(indent .. "from: ", msg:from())
print(indent .. "from addr: ", msg:from_address())
print(indent .. "reply: ", msg:reply_to())
print(indent .. "reply addr: ", msg:reply_address())
print(indent .. "trunc: ", msg:is_truncated())
for i,v in ipairs(msg:full_content()) do
if v.text then print(indent .. " ", i , "TEXT : ", v.type, #v.text)
elseif v.data then print(indent .. " ", i , "FILE : ", v.type, v.disposition, v.file_name or v.name, #v.data)
elseif v.message then print(indent .. " ", i , "RFC822: ", v.type, v.disposition, v.file_name or v.name)
print_msg(v.message, indent .. '\t\t\t')
end
end
end
local mbox = pop3.new()
mbox:open(some_mail.host, some_mail.port or '110')
print('open :', mbox:is_open())
mbox:auth(some_mail.username, some_mail.password)
print('auth :', mbox:is_auth())
for k, msg in mbox:messages() do
print(string.format(" *** MESSAGE NO %d ***", k))
print_msg(msg)
end
```