FAQ

On Wednesday, 12 August 2015 17:00:29 UTC+3, Sean Murphy wrote:
Hey golang-nuts,

After working in go for almost a year now and finding the net/http server
package so eloquent and productive to work in I found myself wanting an
smtp implementation as well.
BTW, there is https://github.com/mhale/smtpd and
more http://godoc.org/?q=smtp

+ Egon

The go project has a few relevant packages that have gotten me to a
successful go mail server (perhaps more just a Mail Exchanger) I then began
wondering if I could create an smtp package that would make it really
simple for devs to start up a smtp server in the same spirit of simplicity
that the http package provides. Something like:

smtp.HandleFunc("ad...@example.com <javascript:>", func(r
*smtp.Connection){
fmt.Println("Incoming message!")
fmt.Println(" RemoteAddr:", r.RemoteAddr)
fmt.Println(" From:", r.From)
for _, t := range r.To{
fmt.Println(" To:", t)
}
fmt.Println(" Message:", r.Message)
}
smtp.DefaultServer.Name = "example.com"
smtp.ListenAndServeTLS(":2525", "cert.pem", "key.pem", nil)

Questions

1. Because smtp is stateful, I'm not really sure how to handle things like
authentication, verification, expand, etc
a. One of my ideas is to make 'handlers' more than a .ServeSMTP(r
*smtp.Request) interface, perhaps it has multiple callbacks for each
command that might come through smtp, but abstracted away from the protocol
a bit. For example verify might have the signature func Verify(email
string) bool, and expand: func Expand(email string) []string
b. I thought about utilizing the handler to 'verify' addresses that the
server can handle. So internally the server would just call the .Handle
method and if the muxer had a registered result than the server would allow
that recipient or respond accordingly to verify command.
c. Authentication would obviously need some callback, should that be on
the server? Or perhaps on the servers handler as mentioned above?
2. The smtp rfc's have recommendations for limits on line length. My idea
is to expand textproto to read lines up to a certain length before they
would return with an error perhaps. This would need some additional
methods, or some way to set the read length on the connection.
3. I'd also like to expand message a bit more, add the ability to set
headers, write/modify the body. It also seems like a good place to throw in
a method for dkim validation and signing.
4. Is there interest for adding this to the standard library?

Proposal

To sum up what I'm thinking:
Add sa server to the net/smtp package
- A default server will be provided
- The default server will use a smtp muxer that surfaces HandleFunc and
Handle methods
Provide byte limit readers to the net/textproto package
Add functionality to the net/message package
- Ability to write new/replace headers

Thanks for taking the time to read through this and consider a
contribution to golang. I hope this sparks a good discussion and gives me a
better idea of whether this would be a valuable contribution.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Manlio Perillo at Aug 12, 2015 at 2:54 pm
    Il giorno mercoledì 12 agosto 2015 16:17:17 UTC+2, Ian Lance Taylor ha
    scritto:
    On Wed, Aug 12, 2015 at 12:16 AM, Sean Murphy <murphy...@gmail.com
    <javascript:>> wrote:
    4. Is there interest for adding this to the standard library?
    I think that Go is a great language for writing an SMTP server and I
    would encourage you to work on it if you are interested.
    I would like to see a Go re-implementation for all the network
    client/servers for "personal" use I have installed on my system.
    Many of these are written in C.

    As an example on my system I have installed:

    - pdns
    - msmtp
    - isync
    - wget
    - curl


    Regards Manlio

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Matt Harden at Aug 12, 2015 at 4:34 pm
    curl/wget: https://github.com/astaxie/bat
    On Wed, Aug 12, 2015 at 9:54 AM Manlio Perillo wrote:



    Il giorno mercoledì 12 agosto 2015 16:17:17 UTC+2, Ian Lance Taylor ha
    scritto:
    On Wed, Aug 12, 2015 at 12:16 AM, Sean Murphy <murphy...@gmail.com>
    wrote:
    4. Is there interest for adding this to the standard library?
    I think that Go is a great language for writing an SMTP server and I
    would encourage you to work on it if you are interested.
    I would like to see a Go re-implementation for all the network
    client/servers for "personal" use I have installed on my system.
    Many of these are written in C.

    As an example on my system I have installed:

    - pdns
    - msmtp
    - isync
    - wget
    - curl


    Regards Manlio

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 12, '15 at 2:44p
activeAug 12, '15 at 4:34p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase