pop3

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 11 Imported by: 0

README

pop3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PopMails

func PopMails(ctx context.Context, cfg POP3ClientConfig, f func(*MailMessage) error) error

Types

type ListItem

type ListItem struct {
	Id   int
	Size int
}

type Mail

type Mail struct {
	RawMessage []byte
	Message    *mail.Message
	UID        []byte
}

type MailMessage

type MailMessage struct {
	From,
	Subject,
	Text string
}

type POP3ClientConfig

type POP3ClientConfig struct {
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	Username string `yaml:"user"`
	Password string `yaml:"pass"`

	// Default is 30 seconds.
	Timeout time.Duration `yaml:"timeout"`

	TLSEnabled    bool `yaml:"tls_enabled"`
	TLSSkipVerify bool `yaml:"tls_skip_verify"`
}

type POP3Conn

type POP3Conn struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"context"
	"time"

	"log"

	"github.com/covrom/pop3"
)

func main() {
	cfg := pop3.POP3ClientConfig{
		Host:          "pop.mail.com",
		Port:          "995", // "110"
		Username:      "tttest@mail.com",
		Password:      "",
		Timeout:       time.Minute,
		TLSEnabled:    true,
		TLSSkipVerify: false,
	}
	if err := pop3.PopMails(context.Background(), cfg, func(msg *pop3.MailMessage) error {
		log.Println(msg.From, msg.Subject, msg.Text)
		return nil
	}); err != nil {
		log.Println(err)
	}
}
Output:

func NewPOP3Conn

func NewPOP3Conn(cfg POP3ClientConfig) (*POP3Conn, error)

func (*POP3Conn) Close

func (c *POP3Conn) Close()

func (*POP3Conn) CloseOnErr

func (c *POP3Conn) CloseOnErr() error

func (*POP3Conn) Delete

func (c *POP3Conn) Delete(id int) error

func (*POP3Conn) GetMail

func (c *POP3Conn) GetMail(ctx context.Context, id int) (*MailMessage, error)

func (*POP3Conn) List

func (c *POP3Conn) List(ctx context.Context) ([]ListItem, error)

func (*POP3Conn) ReadLinesToPoint

func (c *POP3Conn) ReadLinesToPoint(ctx context.Context) *POP3Conn

func (*POP3Conn) ReadOK

func (c *POP3Conn) ReadOK(errstr string) *POP3Conn

func (*POP3Conn) Sendf

func (c *POP3Conn) Sendf(format string, args ...interface{}) *POP3Conn

Jump to

Keyboard shortcuts

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