A simple Go POP3 client library for connecting and reading mails from POP3 servers.

Overview

go-pop3

A simple Go POP3 client library for connecting and reading mails from POP3 servers. This is a full rewrite of TheCreeper/go-pop3 with bug fixes and new features.

Install

go get -u github.com/knadh/go-pop3

Example

import (
	"fmt"
	"github.com/knadh/go-pop3"
)

func main() {
	// Initialize the client.
	p := pop3.New(pop3.Opt{
		Host: "pop.gmail.com",
		Port: 995,
		TLSEnabled: true,
	})

	// Create a new connection. POP3 connections are stateful and should end
	// with a Quit() once the opreations are done.
	c, err := p.NewConn()
	if err != nil {
		log.Fatal(err)
	}
	defer c.Quit()

	// Authenticate.
	if err := c.Auth("myuser", "mypassword"); err != nil {
		log.Fatal(err)
	}

	// Print the total number of messages and their size.
	count, size, _ := c.Stat()
	fmt.Println("total messages=", count, "size=", size)

	// Pull the list of all message IDs and their sizes.
	msgs, _ := c.List(0)
	for _, m := range msgs {
		fmt.Println("id=", m.ID, "size=", m.Size)
	}

	// Pull all messages on the server. Message IDs go from 1 to N.
	for id := 1; id <= count; id++ {
		m, _ := c.Retr(id)

		fmt.Println(id, "=", m.Header.Get("subject"))

		// To read the multi-part e-mail bodies, see:
		// https://github.com/emersion/go-message/blob/master/example_test.go#L12
	}

	// Delete all the messages. Server only executes deletions after a successful Quit()
	for id := 1; id <= count; id++ {
		c.Dele(id)
	}
}

PkgGoDev

To-do: tests

Setup a Docker test environment that runs InBucket POP3 + SMTP server to run a dummy POP3 server and test all the commands in the lib.

Licensed under the MIT License.

Issues
  • Handle `+OK` and `-ERR` without additional info

    Handle `+OK` and `-ERR` without additional info

    • Handle +OK and -ERR responses without additional info (global vars: respOK, respErr).
    • Move bOK inside parseResp() to global var and renamed to respOKInfo.
    • Move bERR inside parseResp() to global var and renamed to respErrInfo.
    • Include actual response in error message.

    Notes:

    • Dovecot returns +OK if authentication succeeds.
    • According to RFC 1081, it's possible server returns +OK and -ERR without additional info. https://datatracker.ietf.org/doc/html/rfc1081
    opened by iredmail 1
Releases(v0.3.0)
Owner
Kailash Nadh
Hobbyist developer | CTO @zerodha | Volunteer @fossunited
Kailash Nadh
A simple parser for the query used in gmail to filter for e-mails

Go Gmail Query Parser by Dustin Breuer This project is work in progress. Prerequisites Before installing this project you need: ?? Go (at least 1.17)

Dustin Breuer 0 Feb 2, 2022
This command line tool exports .eml files from POP3 account.

export-mail This command line tool exports .eml files from POP3 account. Install > go get github.com/gonejack/export-mail Usage > export-mail --host i

会有猫的 0 Dec 6, 2021
Golang package that generates clean, responsive HTML e-mails for sending transactional mail

Hermes Hermes is the Go port of the great mailgen engine for Node.js. Check their work, it's awesome! It's a package that generates clean, responsive

Mathieu Cornic 2.5k Jul 30, 2022
go-pst is a library for reading PST files (written in Go/Golang).

go-pst A library for reading PST files (written in Go/Golang). Introduction go-pst is a library for reading PST files (written in Go/Golang). The PFF

Mooij Technologies 124 Jul 25, 2022
:inbox_tray: An IMAP library for clients and servers

go-imap An IMAP4rev1 library written in Go. It can be used to build a client and/or a server. Usage Client package main import ( "log" "github.com

Simon Ser 1.6k Jul 30, 2022
Monitoring and automation for Open Source email servers, starting with Postfix.

Welcome to Lightmeter Control Center, the Open Source mailops monitoring application.

Lightmeter 87 Jul 18, 2022
Filtering spam in mail server, protecting both client privacy and server algorithm

HE Spamfilter SNUCSE 2021 "Intelligent Computing System Design Project" Hyesun Kwak Myeonghwan Ahn Dongwon Lee abstract Naïve Bayesian spam filtering

Myeonghwan Ahn 1 Mar 23, 2022
Lightweight SMTP client written in Go

Hectane Hectane is both a Go package providing an SMTP queue for sending emails and a standalone application that exposes this functionality via an HT

Hectane 220 Aug 1, 2022
IMAP4rev1 Client for Go

IMAP4rev1 Client for Go ======================= To download and install this package run: go get github.com/mxk/go-imap/imap The documentation is a

Maxim Khitrov 207 Jun 17, 2022
POP-3 client package for Go.

GOP-3 (Go + POP-3) is a POP-3 client for Go. It has experimental purpose and it is still under development. RFC 1939 document has been followed while developing package.

Gökhan Özeloğlu 10 Dec 25, 2021
aerc is an email client for your terminal.

aerc aerc is an email client for your terminal. This is a fork of the original aerc by Drew DeVault. A short demonstration can be found on https://aer

Robin Jarry 10 Jul 31, 2022
📧 Go client for the OhMySMTP email service

go-ohmysmtp A Go wrapper for the OhMySMTP email service. Package https://github.com/jackcoble/go-ohmysmtp Examples Send an email. package main impor

null 0 Dec 13, 2021
aerc is an email client for your terminal.

aerc aerc is an email client for your terminal. This is a fork of the original aerc by Drew DeVault. A short demonstration can be found on https://aer

null 1 Apr 16, 2022
Robust and flexible email library for Go

email Robust and flexible email library for Go Email for humans The email package is designed to be simple to use, but flexible enough so as not to be

Jordan Wright 2.1k Jul 30, 2022
:envelope: A streaming Go library for the Internet Message Format and mail messages

go-message A Go library for the Internet Message Format. It implements: RFC 5322: Internet Message Format RFC 2045, RFC 2046 and RFC 2047: Multipurpos

Simon Ser 260 Jul 18, 2022
A simple CSS parser and inliner in Go

douceur A simple CSS parser and inliner in Golang. Parser is vaguely inspired by CSS Syntax Module Level 3 and corresponding JS parser. Inliner only p

Aymerick 219 Jul 15, 2022
a simple api that sent spam via sms and email

a simple api that sent spam via sms and email routes: /sms /email example request with python

null 3 Oct 19, 2021
📮 Simple (but useful) email sender written in pure Go v1.17. Support HTML templates and attachments.

?? Go Email Sender Simple (but useful) email sender written in pure Go v1.17. Yes, yet another email package here! ?? Support HTML templates and attac

Vic Shóstak 6 Dec 31, 2021
A simple microservice designed in Go using Echo Microframework for sending emails and/or calendar invitations to users.

Calenvite A simple microservice designed in GO using Echo Microframework for sending emails and/or calendar invitations to users. Features Send emails

Adriano Galello 12 Apr 4, 2022