Categorygithub.com/skx/webmail
modulepackage
0.0.0-20201117043321-ba29ccd0beda
Repository: https://github.com/skx/webmail.git
Documentation: pkg.go.dev

# README

Go Report Card license Release

Webmail

This repository contains a simple webmail implementation for golang:

  • You can connect to a remote IMAP server and perform basic operations
    • Retrieve the list of remote folders.
    • Open a folder and see the appropriate messages.
      • Unread messages will be displayed in bold.
      • Messages which have been replied to will be shown with an icon.
      • Messages with attachments will display a "paperclip" next to them.
      • You can page back/forward by 50 messages.
    • For any message in the folder list you can retrieve it
      • Which will also mark the message as being read.
      • The message will be displayed as (filtered) HTML, Plain text, and RAW as applicable.
      • Attachments will be displayed and may be downloaded.

This application has been tested against three remote IMAP hosts:

  • GMail
  • GMX
  • My mailserver, running dovecot.

All perform well, though in all honesty my own server performs the worst because I have ~1000 mailboxes. So just getting the folder list takes some time I'd rather avoid.

Screenshots

There are a collection of screenshots here:

Installation

To install this run:

 ~ $ go get -u github.com/skx/webmail
 ~ $ go install github.com/skx/webmail

Usage

Build the application and start it:

 ~$ webmail

Now point your favourite browser at http://localhost:8080/ and fill in the appropriate details. For example if you wished to test against Google-mail you'd enter the following values:

ValueSetting
Hostimaps://imap.gmail.com/
Username[email protected]
Passwords3cr1t

NOTE: If you want to us IMAP (143) use imap:// as a prefix, if you want IMAPS (993) use imaps://. To avoid issues I'm NOT validating the SSL certificate. This is intentional. Sorry.

Limitations

The main limitation is that this is a naive webmail client, which means that every time you carry out an option the flow goes:

  • Your browser sends a request to this server.
  • The server opens a new connection to the remote IMAP server:
    • The appropriate command(s) are executed.
    • The IMAP server connection is closed.
  • The server sends the response to your client.

This means that things are slower than they would be if there were a dedicated proxy maintaining a persistent connection to the IMAP server.

Missing Features

You cannot:

  • Delete a message.
  • Reply to a message.
  • Forward a message.
  • Compose a fresh message.

Some of those would be simple to add, others more complex.

Hacking

The generated HTML views are stored inside the compiled binary to ease deployment. If you wish to tweak the look & feel by editing them then you're more then welcome.

The raw HTML-templates are located beneath data/, and you can edit them then rebuild the compiled versions via the implant tool.

If you don't already have implant installed fetch it like so:

 go get -u  github.com/skx/implant/
 go install github.com/skx/implant/

Now regenerate the compiled version(s) of the templates and rebuild the binary to make your changes:

go generate
go build

Thanks

This project wouldn't have been possible without the use of some excellent libraries:

Steve

# Functions

AddContext updates our HTTP-handlers to be username-aware.
LoadCookie loads the persistent cookies from disc, if they exist.
NewIMAP returns a new IMAPConnection object.

# Structs

Data used by the frame templates, common to every page .
IMAPConnection handles the the connection to a back-end IMAP(S) server.
IMAPFolder contains details about a single folder.
Data required for rendering the login page .
Message is a very minimal structure for a message in a folder.
SingleMessage is used to display a single message-view.