pop3

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 10 Imported by: 0

README

Go Reference

POP3 Client library

POP3 Client library written in Golang, in accordance to RFC1939 and RFC2449

Based on genert (Thank you G). I added RFC2449 and removed non standard library packages.

Checks server support for CAPA, TOP, and UIDL in accordance to RFC2449

Import location:

import "git.hansaray.pw/go/pop3"

Hostname should include the port:

Hostname = pop.excample.com:995
Username = user@example.com
Password = Long password

See test for use example.

Test:

pop_test.go gets the vars from env. Please set following if you like to run the test:

Hostname = os.Getenv("POP3_HOSTNAME")
Username = os.Getenv("POP3_USERNAME")
Password = os.Getenv("POP3_USERPASS")

Note:

Some email servers let you login to a specific folder.

You need to specify the folder in the Username, such as:

Username = user@excample.com#foldername
Username = foldername#user@excample.com

More info on folders at afterlogic.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug mode will add the Client Info and Error information

Functions

This section is empty.

Types

type Client

type Client struct {

	// server support for POP3 CAPA command
	CapaCAPA bool

	// server support for POP3 TOP command
	CapaTOP bool

	// server support for POP3 UIDL command
	CapaUIDL bool

	// Count of messages
	Count int

	// Size of all messages
	Size int

	List []MessageList

	// List of info messages
	Info []string

	// List of errors
	Errors []error
	// contains filtered or unexported fields
}

Client for POP3 with message list, which represents the metadata returned by the server for a messages stored in the maildrop.

func Dial

func Dial(addr string) (c *Client, err error)

Dial opens new connection and creates a new POP3 client.

func DialTLS

func DialTLS(addr string) (c *Client, err error)

DialTLS opens new TLS connection and creates a new POP3 client.

func NewClient

func NewClient(conn net.Conn) (c *Client, err error)

NewClient creates a new POP3 client.

func (*Client) Authorization

func (c *Client) Authorization(user, pass string) (err error)

Authorization logs into POP3 server with login and password.

func (*Client) Dele

func (c *Client) Dele(msg int) (err error)

Dele will delete the given message from the maildrop. Changes will only take affect after the Quit command is issued.

func (*Client) ListAll

func (c *Client) ListAll() (err error)

ListAll returns a MessageList object which contains all messages in the maildrop.

func (*Client) ListCapabilities

func (c *Client) ListCapabilities() (err error)

CAPA List Capabilities.

func (*Client) Noop

func (c *Client) Noop() (err error)

Noop will do nothing however can prolong the end of a connection.

func (*Client) Quit

func (c *Client) Quit() (err error)

Quit sends the QUIT message to the POP3 server and closes the connection.

func (*Client) Retr

func (c *Client) Retr(msg int) (message *mail.Message, err error)

Retr downloads the given message and returns it as a mail.Message object.

func (*Client) RetrRaw

func (c *Client) RetrRaw(msg int) (message []byte, err error)

RetrRaw downloads the given message and returns it as []byte object.

func (*Client) Rset

func (c *Client) Rset() (err error)

Rset will unmark any messages that have being marked for deletion in the current session.

func (*Client) Stat

func (c *Client) Stat() (err error)

Stat retrieves a drop listing for the current maildrop, consisting of the number of messages and the total size (in octets) of the maildrop. In the event of an error, all returned numeric values will be 0.

func (*Client) Status

func (c *Client) Status() bool

Status checks if we are connected to a pop3 server

func (*Client) Top

func (c *Client) Top() (headers []string, err error)

TOP Return headers.

type Connection

type Connection struct {
	Reader *textproto.Reader
	Writer *textproto.Writer
	// contains filtered or unexported fields
}

Client holds the net conn and read/write buffer objects.

func NewConnection

func NewConnection(conn io.ReadWriteCloser) *Connection

NewConnection initializes a connection.

func (*Connection) Close

func (c *Connection) Close() error

Close closes a connection.

func (*Connection) Cmd

func (c *Connection) Cmd(format string, args ...interface{}) (string, error)

Cmd sends the given command on the connection.

func (*Connection) ReadDot

func (c *Connection) ReadDot() (raw []byte, err error)

ReadDot returns the raw mail message.

func (*Connection) ReadLine

func (c *Connection) ReadLine() (string, error)

ReadLine reads a single line from the buffer.

func (*Connection) ReadLines

func (c *Connection) ReadLines() (lines []string, err error)

ReadLines reads from the buffer until it hits the message end dot (".").

type MessageList

type MessageList struct {
	// Non unique id reported by the server
	ID int

	// Unique id reported by the server
	UID string

	// Size of the message
	Size int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL