Giter Site home page Giter Site logo

gleez / smtpd Goto Github PK

View Code? Open in Web Editor NEW
200.0 13.0 48.0 264 KB

A Lightweight High Performance ESMTP email server

License: MIT License

Go 82.45% CSS 1.94% JavaScript 4.88% HTML 10.73%
smtpd golang esmtp-server esmtp c10k http mongodb smtp smtp-server high-performance

smtpd's Introduction

smtpd

A Lightweight High Performance SMTP written in Go, made for receiving large volumes of mail, parse and store in mongodb. The purpose of this daemon is to grab the email, save it to the database and disconnect as quickly as possible.

This server does not attempt to check for spam or do any sender verification. These steps should be performed by other programs. The server does NOT send any email including bounces. This should be performed by a separate program.

The most alluring aspect of Go are the Goroutines! It makes concurrent programming easy, clean and fun! Go programs can also take advantage of all your machine's multiple cores without much effort that you would otherwise need with forking or managing your event loop callbacks, etc. Golang solves the C10K problem in a very interesting way http://en.wikipedia.org/wiki/C10k_problem

Once compiled, Smtpd does not have an external dependencies (HTTP, SMTP are all built in).

Features

  • ESMTP server implementing RFC5321
  • Support for SMTP AUTH (RFC4954) and PIPELINING (RFC2920)
  • Multipart MIME support
  • UTF8 support for subject and message
  • Web interface to view messages (plain text, HTML or source)
  • Html sanitizer for html mail in web interface
  • Real-time updates using websocket
  • Download individual attachments
  • MongoDB storage for message persistence
  • Lightweight and portable
  • No installation required

Development Status

SMTPD is currently production quality: it is being used for real work.

TODO

  • POP3
  • Rest API
  • Inline resources in Web interface
  • Per user/domain mailbox in web interface

Building from Source

You will need a functioning [Go installation][Golang] for this to work.

Grab the Smtpd source code and compile the daemon:

go get -v github.com/gleez/smtpd

Edit etc/smtpd.conf and tailor to your environment. It should work on most Unix and OS X machines as is. Launch the daemon:

$GOPATH/bin/smtpd -config=$GOPATH/src/github.com/gleez/smtpd/etc/smtpd.conf

By default the SMTP server will be listening on localhost port 25000 and the web interface will be available at localhost:10025.

This will place smtpd in the background and continue running

/usr/bin/nohup /home/gleez/smtpd -config=/home/gleez/smtpd.conf -logfile=smtpd.log 2>&1 &

You may also put another process to watch your smtpd process and re-start it if something goes wrong.

Using Nginx as a proxy

Nginx can be used to proxy SMTP traffic for GoGuerrilla SMTPd

Why proxy SMTP?

  • Terminate TLS connections: At present, only a partial implementation of TLS is provided. OpenSSL on the other hand, used in Nginx, has a complete implementation of SSL v2/v3 and TLS protocols.
  • Could be used for load balancing and authentication in the future.
  1. Compile nginx with --with-mail --with-mail_ssl_module
  2. Configuration:
mail {
	#This is the URL to Smtpd's http service which tells Nginx where to proxy the traffic to
	auth_http 127.0.0.1:10025/auth-smtp;
					
	server {
		listen  15.29.8.163:25;
		protocol     smtp;
		server_name  smtp.example.com;

		smtp_auth none;
		timeout 30000;
		smtp_capabilities "PIPELINING" "8BITMIME" "SIZE 20480000";

		# ssl default off. Leave off if starttls is on
		#ssl                   on;
		ssl_certificate        /etc/ssl/certs/ssl-cert-snakeoil.pem;
		ssl_certificate_key    /etc/ssl/private/ssl-cert-snakeoil.key;
		ssl_session_timeout    5m;

		ssl_protocols               SSLv2 SSLv3 TLSv1;
		ssl_ciphers                 HIGH:!aNULL:!MD5;
		ssl_prefer_server_ciphers   on;

		# TLS off unless client issues STARTTLS command
		starttls      on;
		proxy         on;
		xclient       on;
	}
}

Credits

Licence

Copyright ยฉโ€Ž 2014, Gleez Technologies (http://www.gleeztech.com).

Released under MIT license, see LICENSE for details.

smtpd's People

Contributors

sandeepone avatar

Stargazers

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

Watchers

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

smtpd's Issues

panic: runtime error: cgo argument has Go pointer to Go pointer

$ $GOPATH/bin/smtpd -config=/a/src/smtpd/smtpd.conf
2018/01/06 19:59:34 [INFO ] Smtpd 1.1 (undefined) starting...
2018/01/06 19:59:34 [INFO ] Incus Websocket Init
2018/01/06 19:59:34 [INFO ] Theme templates mapped to './themes/cerber/templates'
2018/01/06 19:59:34 [INFO ] Theme static content mapped to './themes/cerber/public'
2018/01/06 19:59:34 [TRACE] Loading the certificate: smtp.pem
2018/01/06 19:59:34 [INFO ] HTTP listening on TCP4 0.0.0.0:10025
2018/01/06 19:59:34 [INFO ] SMTP listening on TCP4 0.0.0.0:25000
2018/01/06 19:59:34 [INFO ] Trying MongoDB storage
2018/01/06 19:59:34 [TRACE] Connecting to MongoDB: 127.0.0.1:27017
2018/01/06 19:59:34 [INFO ] Using MongoDB storage
2018/01/06 19:59:34 [TRACE] Running SaveMail Rotuines
2018/01/06 19:59:34 [TRACE] Running SaveMail Rotuines
2018/01/06 19:59:34 [TRACE] Running SaveMail Rotuines
2018/01/06 19:59:42 [TRACE] Web: [::1]:44686 HTTP/1.1 GET /
2018/01/06 19:59:42 [TRACE] Parsing template themes/cerber/templates/root/index.html
2018/01/06 20:00:01 [TRACE] Web: [::1]:44690 HTTP/1.1 GET /login
2018/01/06 20:00:01 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:00:07 [TRACE] Web: [::1]:44690 HTTP/1.1 GET /status
2018/01/06 20:00:07 [TRACE] This page requires a login.
2018/01/06 20:00:07 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:00:11 [TRACE] Web: [::1]:44690 HTTP/1.1 GET /mails
2018/01/06 20:00:11 [TRACE] Loading Mails from Mongodb
2018/01/06 20:00:11 [TRACE] This page requires a login.
2018/01/06 20:00:11 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:04:58 [TRACE] Web: [::1]:44782 HTTP/1.1 GET /
2018/01/06 20:04:58 [TRACE] Parsing template themes/cerber/templates/root/index.html
2018/01/06 20:05:03 [TRACE] Web: [::1]:44784 HTTP/1.1 GET /status
2018/01/06 20:05:03 [TRACE] This page requires a login.
2018/01/06 20:05:03 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:05:12 [TRACE] Web: [::1]:44784 HTTP/1.1 GET /register
2018/01/06 20:05:12 [TRACE] Parsing template themes/cerber/templates/common/signup.html
2018/01/06 20:05:41 [TRACE] Web: [::1]:44784 HTTP/1.1 POST /register
2018/01/06 20:05:41 [TRACE] Registration successful
2018/01/06 20:05:41 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:05:51 [TRACE] Web: [::1]:44784 HTTP/1.1 POST /login
2018/01/06 20:05:51 [TRACE] Login successful for session <ObjectIdHex("5a519c950113894fb55ae5b9")>
2018/01/06 20:05:51 [TRACE] The user is not activated
2018/01/06 20:05:51 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:07:19 [TRACE] Web: [::1]:44794 HTTP/1.1 POST /login
2018/01/06 20:07:19 [TRACE] Login successful for session <ObjectIdHex("5a519c950113894fb55ae5b9")>
2018/01/06 20:07:19 [TRACE] The user is not activated
2018/01/06 20:07:19 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:07:28 [TRACE] Web: [::1]:44794 HTTP/1.1 GET /register
2018/01/06 20:07:28 [TRACE] Parsing template themes/cerber/templates/common/signup.html
2018/01/06 20:07:52 [TRACE] Web: [::1]:44794 HTTP/1.1 POST /register
2018/01/06 20:07:52 [TRACE] Registration successful
2018/01/06 20:07:52 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:07:55 [TRACE] Web: [::1]:44794 HTTP/1.1 GET /
2018/01/06 20:07:55 [TRACE] Parsing template themes/cerber/templates/root/index.html
2018/01/06 20:07:57 [TRACE] Web: [::1]:44794 HTTP/1.1 GET /status
2018/01/06 20:07:57 [TRACE] This page requires a login.
2018/01/06 20:07:57 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:07:58 [TRACE] Web: [::1]:44794 HTTP/1.1 POST /login
2018/01/06 20:07:58 [TRACE] Login successful for session <ObjectIdHex("5a519c950113894fb55ae5b9")>
2018/01/06 20:07:58 [TRACE] The user is not activated
2018/01/06 20:07:58 [TRACE] Parsing template themes/cerber/templates/common/login.html
2018/01/06 20:08:56 [INFO ] There are now 16 serving goroutines
2018/01/06 20:08:56 [INFO ] SMTP Connection from 127.0.0.1:40490, starting session <1>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 62 bytes: smtpd.local Gleez SMTP # 1 (1) Sat, 06 Jan 2018 20:08:56 -0800 >>
2018/01/06 20:08:56 [INFO ] SMTP[127.0.0.1]<1> Remote Client is Trusted: <127.0.0.1>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << EHLO digilicious.com <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'EHLO', args 'digilicious.com'
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 32 bytes: Hello digilicious.com[127.0.0.1] >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 10 bytes: PIPELINING >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 8 bytes: 8BITMIME >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 8 bytes: STARTTLS >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 34 bytes: AUTH EXTERNAL CRAM-MD5 LOGIN PLAIN >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 13 bytes: SIZE 20480000 >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << STARTTLS <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'STARTTLS', args ''
2018/01/06 20:08:56 [TRACE] Ready to start TLS
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 18 bytes: Ready to start TLS >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << EHLO digilicious.com <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'EHLO', args 'digilicious.com'
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 32 bytes: Hello digilicious.com[127.0.0.1] >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 10 bytes: PIPELINING >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 8 bytes: 8BITMIME >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 34 bytes: AUTH EXTERNAL CRAM-MD5 LOGIN PLAIN >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 13 bytes: SIZE 20480000 >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << MAIL FROM:[email protected] SIZE=3445 BODY=8BITMIME <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'MAIL', args 'FROM:[email protected] SIZE=3445 BODY=8BITMIME'
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> ESMTP params: map[SIZE:3445 BODY:8BITMIME]
2018/01/06 20:08:56 [INFO ] SMTP[127.0.0.1]<1> Mail from: [email protected]
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 52 bytes: Roger, accepting mail from [email protected] >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << RCPT TO:[email protected] <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'RCPT', args 'TO:[email protected]'
2018/01/06 20:08:56 [INFO ] SMTP[127.0.0.1]<1> Recipient: [email protected]
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 50 bytes: I'll make sure [email protected] gets this >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> << DATA <<
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> In state 1, got command 'DATA', args ''
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> Enter dataHandler 1
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> Go ahead we have recipients 1
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> >> Sent 46 bytes: Go ahead. End your data with . >>
2018/01/06 20:08:56 [TRACE] SMTP[127.0.0.1]<1> Got EOF, storing message and switching to MAIL state
2018/01/06 20:08:56 [TRACE] Reading Mail Message
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 22 [running]:
github.com/sloonz/go-iconv.(*Iconv).Conv.func1(0x7fc5bc000c20, 0xc4201f0088, 0xc420536c68, 0xc4201f0098, 0xc420536ce0, 0x200, 0x8, 0x8bf720)
/z/home/gene/go/src/github.com/sloonz/go-iconv/iconv.go:60 +0x8b
github.com/sloonz/go-iconv.(*Iconv).Conv(0xc4201f0080, 0xc420175320, 0x1a, 0x0, 0xc4201f0080, 0x0, 0x0)
/z/home/gene/go/src/github.com/sloonz/go-iconv/iconv.go:60 +0x1ef
github.com/sloonz/go-iconv.Conv(0xc420175320, 0x1a, 0x932ed8, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/z/home/gene/go/src/github.com/sloonz/go-iconv/iconv.go:79 +0xdd
github.com/gleez/smtpd/data.MimeHeaderDecode(0xc420175320, 0x1a, 0x7, 0xc4201752c0)
/z/home/gene/go/src/github.com/gleez/smtpd/data/message.go:326 +0xf9
github.com/gleez/smtpd/data.ParseSMTPMessage(0xc42026cc80, 0xc420013767, 0xb, 0x1, 0x0)
/z/home/gene/go/src/github.com/gleez/smtpd/data/message.go:104 +0xb7a
github.com/gleez/smtpd/data.(*DataStore).SaveMail(0xc4201b82a0)
/z/home/gene/go/src/github.com/gleez/smtpd/data/storage.go:65 +0xc6
created by github.com/gleez/smtpd/data.(*DataStore).StorageConnect
/z/home/gene/go/src/github.com/gleez/smtpd/data/storage.go:47 +0x157

not able to run without mongodb

Does memory storage implemented at all?
I'm try to set memory and get error:
Failed to parse config: Failed to parse [datastore]mongo.uri: 'option not found: mongo.uri'

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.