Code Monkey home page Code Monkey logo

lua-pop3's Introduction

lua-pop3

Build status

Licence Build Status Coverage Status

POP3 client library for Lua 5.1 / 5.2 / 5.3

Dependences

Decode text headers/content

Parse from/to/reply headers

MD5 modules

APOP auth

CRAM MD5 auth

Detect current codepage on Windows

Usage

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 '[email protected]';
  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

lua-pop3's People

Contributors

bitdeli-chef avatar moteus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.