FAQ
Hello, I wrote a new package: gomail. It provides a simple interface to
easily write and send emails. It supports attachments, multipart emails and
encoding of non-ASCII characters.

Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
Source code: https://github.com/alexcesaro/mail/

Here is an example:

     package main

     import (
         "log"

         "github.com/alexcesaro/mail/gomail"
     )

     func main() {
         msg := gomail.NewMessage()
         msg.SetAddressHeader("From", "alex@example.com", "Alex")
         msg.SetHeader("To", "bob@example.com")
         msg.AddHeader("To", "cora@example.com")
         msg.SetHeader("Subject", "Hello!")
         msg.SetBody("text/plain", "Hello Bob and Cora!")
         msg.AddAlternative("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
         if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
             log.Println(err)
             return
         }

         m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
         if err := m.Send(msg); err != nil { // This will send the email to
Bob and Cora
             log.Println(err)
         }
     }

Hope you will enjoy it! Feedback is welcome!

--
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

  • Luke Mauldin at Jun 26, 2014 at 5:31 pm
    I just want to say THANK YOU for making a package like this. I have had to
    do this at a couple of different employers and I always wrote my own custom
    package (that is not as full-featured) as yours. Unfortunately, I don't
    have the opportunity to use Go in my current position but in the future I
    will definitely use your package for emailing.

    Luke
    On Thursday, June 26, 2014 11:28:54 AM UTC-5, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com <javascript:>",
    "Alex")
    msg.SetHeader("To", "b...@example.com <javascript:>")
    msg.AddHeader("To", "co...@example.com <javascript:>")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email to
    Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Jun 27, 2014 at 12:39 pm
    Glad it helps!

    On Thu, Jun 26, 2014 at 7:31 PM, Luke Mauldin wrote:

    I just want to say THANK YOU for making a package like this. I have had
    to do this at a couple of different employers and I always wrote my own
    custom package (that is not as full-featured) as yours. Unfortunately, I
    don't have the opportunity to use Go in my current position but in the
    future I will definitely use your package for emailing.

    Luke

    On Thursday, June 26, 2014 11:28:54 AM UTC-5, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")

    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alex Howard at Jun 30, 2014 at 12:36 pm
    Thanks dude will be using this library in my social network for outgoing
    email to replace Mailgun API :)

    On Thursday, 26 June 2014 18:28:54 UTC+2, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com <javascript:>",
    "Alex")
    msg.SetHeader("To", "b...@example.com <javascript:>")
    msg.AddHeader("To", "co...@example.com <javascript:>")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email to
    Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Jul 1, 2014 at 10:02 am
    Cool. Please open issues on Github if you find bugs.

    On Mon, Jun 30, 2014 at 2:35 PM, Alex Howard wrote:

    Thanks dude will be using this library in my social network for outgoing
    email to replace Mailgun API :)

    On Thursday, 26 June 2014 18:28:54 UTC+2, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")

    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Oct 15, 2014 at 4:07 pm
    I just released a new version of Gomail in a new repository:
    https://github.com/go-gomail/gomail

    The new version of Gomail has new features (embedded images, custom
    SendMail function...), better performances and a simpler API!
    It also uses gopkg.in for versioning.

    Please note that it is not backward compatible with the old version.
    However I wrote a small guide to update to the new version:
    https://github.com/alexcesaro/mail

    Any feedback appreciated!
    On Tue, Jul 1, 2014 at 12:01 PM, Alexandre Cesaro wrote:

    Cool. Please open issues on Github if you find bugs.

    On Mon, Jun 30, 2014 at 2:35 PM, Alex Howard wrote:

    Thanks dude will be using this library in my social network for outgoing
    email to replace Mailgun API :)

    On Thursday, 26 June 2014 18:28:54 UTC+2, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")

    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Ed Pelc at Oct 17, 2014 at 1:23 am
    Thank you for this. I haven't spent to much time on email yet(just some
    basic registration links for development) but formatting everything
    correctly was a pain. This should save a lot of time later.
    On Wednesday, October 15, 2014 12:07:42 PM UTC-4, Alexandre Cesaro wrote:

    I just released a new version of Gomail in a new repository:
    https://github.com/go-gomail/gomail

    The new version of Gomail has new features (embedded images, custom
    SendMail function...), better performances and a simpler API!
    It also uses gopkg.in for versioning.

    Please note that it is not backward compatible with the old version.
    However I wrote a small guide to update to the new version:
    https://github.com/alexcesaro/mail

    Any feedback appreciated!

    On Tue, Jul 1, 2014 at 12:01 PM, Alexandre Cesaro <alexandr...@gmail.com
    <javascript:>> wrote:
    Cool. Please open issues on Github if you find bugs.


    On Mon, Jun 30, 2014 at 2:35 PM, Alex Howard <3du...@gmail.com
    <javascript:>> wrote:
    Thanks dude will be using this library in my social network for outgoing
    email to replace Mailgun API :)

    On Thursday, 26 June 2014 18:28:54 UTC+2, Alexandre Cesaro wrote:

    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")

    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Jonas Riedel at Oct 17, 2014 at 6:30 pm
    Nice thing !

    Could you provide a send function where the tls config is exposed so that
    one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com <javascript:>",
    "Alex")
    msg.SetHeader("To", "b...@example.com <javascript:>")
    msg.AddHeader("To", "co...@example.com <javascript:>")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email to
    Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Klaus Post at Oct 18, 2014 at 10:14 am
    Very funny - I just ran into the exact same issue yesterday. I tried to
    copy the send function from smtp to my own package, but I gave up since it
    relied on to much package stuff.

    The issue is that TLS in the golang smtp package always attempts smtp, if
    the server announces it. If it fails (we have an expired certificate in our
    case), the client fails, and doesn't attempt a non-TLS connection.

    See http://golang.org/src/pkg/net/smtp/smtp.go?s=1593:1652#L282 for the
    offending code path.

    So yes - if you could make TLS optional that would be great.

    /Klaus

    PS. Thanks for the nice package, it has been very easy to use!

    On Friday, October 17, 2014 8:28:18 PM UTC+2, Jonas Riedel wrote:

    Nice thing !

    Could you provide a send function where the tls config is exposed so that
    one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Oct 20, 2014 at 1:57 pm
    Ok, this is often requested so I will work on an alternative SendMail
    function.
    On Sat, Oct 18, 2014 at 12:14 PM, Klaus Post wrote:

    Very funny - I just ran into the exact same issue yesterday. I tried to
    copy the send function from smtp to my own package, but I gave up since it
    relied on to much package stuff.

    The issue is that TLS in the golang smtp package always attempts smtp, if
    the server announces it. If it fails (we have an expired certificate in our
    case), the client fails, and doesn't attempt a non-TLS connection.

    See http://golang.org/src/pkg/net/smtp/smtp.go?s=1593:1652#L282 for the
    offending code path.

    So yes - if you could make TLS optional that would be great.

    /Klaus

    PS. Thanks for the nice package, it has been very easy to use!


    On Friday, October 17, 2014 8:28:18 PM UTC+2, Jonas Riedel wrote:

    Nice thing !

    Could you provide a send function where the tls config is exposed so that
    one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Oct 20, 2014 at 3:24 pm
    Could you try this SendMail function (using gomail.SetSendMail(sendMail))
    and tell me if it works when the certificate is invalid?


    func sendMail(addr string, a smtp.Auth, from string, to []string, msg
    []byte) error {
    c, err := smtp.Dial(addr)
    if err != nil {
    return err
    }
    defer c.Close()
    if ok, _ := c.Extension("STARTTLS"); ok {
    host, _, _ := net.SplitHostPort(addr)
    config := &tls.Config{ServerName: host, InsecureSkipVerify: true}
    if err = c.StartTLS(config); err != nil {
    return err
    }
    }
    if a != nil {
    if ok, _ := c.Extension("AUTH"); ok {
    if err = c.Auth(a); err != nil {
    return err
    }
    }
    }
    if err = c.Mail(from); err != nil {
    return err
    }
    for _, addr := range to {
    if err = c.Rcpt(addr); err != nil {
    return err
    }
    }
    w, err := c.Data()
    if err != nil {
    return err
    }
    _, err = w.Write(msg)
    if err != nil {
    return err
    }
    err = w.Close()
    if err != nil {
    return err
    }
    return c.Quit()
    }
    On Mon, Oct 20, 2014 at 3:56 PM, Alexandre Cesaro wrote:

    Ok, this is often requested so I will work on an alternative SendMail
    function.
    On Sat, Oct 18, 2014 at 12:14 PM, Klaus Post wrote:

    Very funny - I just ran into the exact same issue yesterday. I tried to
    copy the send function from smtp to my own package, but I gave up since it
    relied on to much package stuff.

    The issue is that TLS in the golang smtp package always attempts smtp, if
    the server announces it. If it fails (we have an expired certificate in our
    case), the client fails, and doesn't attempt a non-TLS connection.

    See http://golang.org/src/pkg/net/smtp/smtp.go?s=1593:1652#L282 for the
    offending code path.

    So yes - if you could make TLS optional that would be great.

    /Klaus

    PS. Thanks for the nice package, it has been very easy to use!


    On Friday, October 17, 2014 8:28:18 PM UTC+2, Jonas Riedel wrote:

    Nice thing !

    Could you provide a send function where the tls config is exposed so
    that one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface to
    easily write and send emails. It supports attachments, multipart emails and
    encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456", 25)
    if err := m.Send(msg); err != nil { // This will send the email
    to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Jonas Riedel at Oct 21, 2014 at 6:31 am
    Thanks Alexandre, your "new" sendMail Function Solution works for me. Great
    work !


    Am Montag, 20. Oktober 2014 17:25:06 UTC+2 schrieb Alexandre Cesaro:
    Could you try this SendMail function (using gomail.SetSendMail(sendMail))
    and tell me if it works when the certificate is invalid?


    func sendMail(addr string, a smtp.Auth, from string, to []string, msg
    []byte) error {
    c, err := smtp.Dial(addr)
    if err != nil {
    return err
    }
    defer c.Close()
    if ok, _ := c.Extension("STARTTLS"); ok {
    host, _, _ := net.SplitHostPort(addr)
    config := &tls.Config{ServerName: host, InsecureSkipVerify: true}
    if err = c.StartTLS(config); err != nil {
    return err
    }
    }
    if a != nil {
    if ok, _ := c.Extension("AUTH"); ok {
    if err = c.Auth(a); err != nil {
    return err
    }
    }
    }
    if err = c.Mail(from); err != nil {
    return err
    }
    for _, addr := range to {
    if err = c.Rcpt(addr); err != nil {
    return err
    }
    }
    w, err := c.Data()
    if err != nil {
    return err
    }
    _, err = w.Write(msg)
    if err != nil {
    return err
    }
    err = w.Close()
    if err != nil {
    return err
    }
    return c.Quit()
    }

    On Mon, Oct 20, 2014 at 3:56 PM, Alexandre Cesaro <alexandr...@gmail.com
    <javascript:>> wrote:
    Ok, this is often requested so I will work on an alternative SendMail
    function.

    On Sat, Oct 18, 2014 at 12:14 PM, Klaus Post <klau...@gmail.com
    <javascript:>> wrote:
    Very funny - I just ran into the exact same issue yesterday. I tried to
    copy the send function from smtp to my own package, but I gave up since it
    relied on to much package stuff.

    The issue is that TLS in the golang smtp package always attempts smtp,
    if the server announces it. If it fails (we have an expired certificate in
    our case), the client fails, and doesn't attempt a non-TLS connection.

    See http://golang.org/src/pkg/net/smtp/smtp.go?s=1593:1652#L282 for the
    offending code path.

    So yes - if you could make TLS optional that would be great.

    /Klaus

    PS. Thanks for the nice package, it has been very easy to use!


    On Friday, October 17, 2014 8:28:18 PM UTC+2, Jonas Riedel wrote:

    Nice thing !

    Could you provide a send function where the tls config is exposed so
    that one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface
    to easily write and send emails. It supports attachments, multipart emails
    and encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456",
    25)
    if err := m.Send(msg); err != nil { // This will send the
    email to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Alexandre Cesaro at Oct 22, 2014 at 9:10 pm
    I added a new setting to easily skip the TLS verification:

    mailer := gomail.NewMailer("smtp.example.com", "user", "123456", 587,
    gomail.SetTLSConfig(&tls.Config{InsecureSkipVerify: true}))
    On Tue, Oct 21, 2014 at 8:31 AM, Jonas Riedel wrote:

    Thanks Alexandre, your "new" sendMail Function Solution works for me.
    Great work !


    Am Montag, 20. Oktober 2014 17:25:06 UTC+2 schrieb Alexandre Cesaro:
    Could you try this SendMail function (using gomail.SetSendMail(sendMail))
    and tell me if it works when the certificate is invalid?


    func sendMail(addr string, a smtp.Auth, from string, to []string, msg
    []byte) error {
    c, err := smtp.Dial(addr)
    if err != nil {
    return err
    }
    defer c.Close()
    if ok, _ := c.Extension("STARTTLS"); ok {
    host, _, _ := net.SplitHostPort(addr)
    config := &tls.Config{ServerName: host, InsecureSkipVerify: true}
    if err = c.StartTLS(config); err != nil {
    return err
    }
    }
    if a != nil {
    if ok, _ := c.Extension("AUTH"); ok {
    if err = c.Auth(a); err != nil {
    return err
    }
    }
    }
    if err = c.Mail(from); err != nil {
    return err
    }
    for _, addr := range to {
    if err = c.Rcpt(addr); err != nil {
    return err
    }
    }
    w, err := c.Data()
    if err != nil {
    return err
    }
    _, err = w.Write(msg)
    if err != nil {
    return err
    }
    err = w.Close()
    if err != nil {
    return err
    }
    return c.Quit()
    }

    On Mon, Oct 20, 2014 at 3:56 PM, Alexandre Cesaro <alexandr...@gmail.com>
    wrote:
    Ok, this is often requested so I will work on an alternative SendMail
    function.
    On Sat, Oct 18, 2014 at 12:14 PM, Klaus Post wrote:

    Very funny - I just ran into the exact same issue yesterday. I tried to
    copy the send function from smtp to my own package, but I gave up since it
    relied on to much package stuff.

    The issue is that TLS in the golang smtp package always attempts smtp,
    if the server announces it. If it fails (we have an expired certificate in
    our case), the client fails, and doesn't attempt a non-TLS connection.

    See http://golang.org/src/pkg/net/smtp/smtp.go?s=1593:1652#L282 for
    the offending code path.

    So yes - if you could make TLS optional that would be great.

    /Klaus

    PS. Thanks for the nice package, it has been very easy to use!


    On Friday, October 17, 2014 8:28:18 PM UTC+2, Jonas Riedel wrote:

    Nice thing !

    Could you provide a send function where the tls config is exposed so
    that one is able to set the InsecureSkipVerify flag for StartTLS ?

    Thanks,

    Jonas

    Am Donnerstag, 26. Juni 2014 18:28:54 UTC+2 schrieb Alexandre Cesaro:
    Hello, I wrote a new package: gomail. It provides a simple interface
    to easily write and send emails. It supports attachments, multipart emails
    and encoding of non-ASCII characters.

    Documentation: http://godoc.org/github.com/alexcesaro/mail/gomail
    Source code: https://github.com/alexcesaro/mail/

    Here is an example:

    package main

    import (
    "log"

    "github.com/alexcesaro/mail/gomail"
    )

    func main() {
    msg := gomail.NewMessage()
    msg.SetAddressHeader("From", "al...@example.com", "Alex")
    msg.SetHeader("To", "b...@example.com")
    msg.AddHeader("To", "co...@example.com")
    msg.SetHeader("Subject", "Hello!")
    msg.SetBody("text/plain", "Hello Bob and Cora!")
    msg.AddAlternative("text/html", "Hello <b>Bob</b> and
    <i>Cora</i>!")
    if err := msg.Attach("/home/Alex/lolcat.jpg"); err != nil {
    log.Println(err)
    return
    }

    m := gomail.NewMailer("smtp.example.com", "user", "123456",
    25)
    if err := m.Send(msg); err != nil { // This will send the
    email to Bob and Cora
    log.Println(err)
    }
    }

    Hope you will enjoy it! Feedback is welcome!
    --
    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.
  • Braden at Oct 23, 2014 at 2:21 am
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the format=flowed parameter
    for text/plain content types? It seems like a nice way to send plain text.

    For reference:

         http://www.ietf.org/rfc/rfc3676.txt
         http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
       Braden

    --
    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.
  • Alexandre Cesaro at Oct 23, 2014 at 6:54 am
    I'm not sure: it does not seem to be a very widespread standard and it only
    works with ASCII-only texts.

    However you can open an issue on Github if you want and we will discuss it
    there.
    On Wed, Oct 22, 2014 at 11:39 PM, wrote:

    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the format=flowed parameter
    for text/plain content types? It seems like a nice way to send plain text.

    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Alexandre Cesaro at Oct 24, 2014 at 10:59 pm
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the body to 8bit
    <https://tools.ietf.org/html/rfc2045#section-6.1> (but still encode special
    characters in headers using quoted-printable).

    Is that fine with you?
    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett wrote:

    Hi,

    Actually, since I end up formatting the plain text version myself, I can
    get pretty close to what I need simply by appending "; format=flowed" to
    the contentType string of the Message receiver's SetBody function.
    (Though I don't know if that is an ideal way of going about it.)

    However, as per RFC3637, I'd like to be able to have the plain/text body
    (and only it) not be encoded as quoted printable. Is there a way to
    turn off quoted printable encoding for a given part of the mail message?

    Thanks,
    Braden

    On Thu, Oct 23, 2014 at 08:58:35AM -0700, braden@smashwords.com wrote:
    I just know I often see emails in my inbox with it, and those emails end up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I didn't see that
    mentioned in the RFC, and many of the format=flowed emails I receive are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden
    On Wednesday, October 22, 2014 11:55:19 PM UTC-7, Alexandre Cesaro wrote:

    I'm not sure: it does not seem to be a very widespread standard and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want and we will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the format=flowed
    parameter
    for text/plain content types? It seems like a nice way to send plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Alexandre Cesaro at Oct 24, 2014 at 11:32 pm
    Yes HTML would not be encoded.

    I can also add a soft line break after the last space before 78 characters.
    On Sat, Oct 25, 2014 at 1:16 AM, Braden Pellett wrote:

    Hi,

    Yeah, I think that could work. Though, just to be clear, would that
    mean that in a plain and html alternative message, the text/html part
    would also not be encoded quoted-printable? Which I think would mean I
    need to be sure to not pass HTML with very long lines (i.e. more than
    998 characters before the newline)?

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 12:58:28AM +0200, Alexandre Cesaro wrote:
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the body to 8bit
    <https://tools.ietf.org/html/rfc2045#section-6.1> (but still encode special
    characters in headers using quoted-printable).

    Is that fine with you?

    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett <braden@smashwords.com>
    wrote:
    Hi,

    Actually, since I end up formatting the plain text version myself, I
    can
    get pretty close to what I need simply by appending "; format=flowed"
    to
    the contentType string of the Message receiver's SetBody function.
    (Though I don't know if that is an ideal way of going about it.)

    However, as per RFC3637, I'd like to be able to have the plain/text
    body
    (and only it) not be encoded as quoted printable. Is there a way to
    turn off quoted printable encoding for a given part of the mail
    message?
    Thanks,
    Braden

    On Thu, Oct 23, 2014 at 08:58:35AM -0700, braden@smashwords.com wrote:
    I just know I often see emails in my inbox with it, and those emails
    end
    up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I didn't see that
    mentioned in the RFC, and many of the format=flowed emails I receive
    are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden

    On Wednesday, October 22, 2014 11:55:19 PM UTC-7, Alexandre Cesaro
    wrote:
    I'm not sure: it does not seem to be a very widespread standard
    and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want and we will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the format=flowed
    parameter
    for text/plain content types? It seems like a nice way to send
    plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Alexandre Cesaro at Oct 25, 2014 at 12:19 am
    If I add the "Unencoded" setting I want it to be respectful of MIME
    specifications. That's why I want to insert soft line breaks before 78
    characters.
    But I don't want to automatically modify the user's inputs (like adding a
    space before "From" or format=flowed in the header).

    Anyway with theses changes you will be able to format your input to be f=f
    compliant.

    On Sat, Oct 25, 2014 at 1:44 AM, Braden Pellett wrote:

    Oh, I don't think you need to concern yourself with the wrapping if it
    doesn't seem generally applicable... I already am post-processing the
    HTML part and have a wrapping method to generate the format=flowed plain
    text, so I could just reuse that to prevent long lines in the HTML.

    Alternatively, if you are going to do soft line breaks for long lines,
    you could perhaps just go all in and provide a format=flowed formatting
    option, :)

    I just did it like this:

    https://github.com/daBrado/tplmail/blob/master/utils.go#L57-L77

    ...for a given line at a time, anyway. Not that this is ideal... I'm
    still new to Go..!

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 01:31:24AM +0200, Alexandre Cesaro wrote:
    Yes HTML would not be encoded.

    I can also add a soft line break after the last space before 78
    characters.
    On Sat, Oct 25, 2014 at 1:16 AM, Braden Pellett <braden@smashwords.com>
    wrote:
    Hi,

    Yeah, I think that could work. Though, just to be clear, would that
    mean that in a plain and html alternative message, the text/html part
    would also not be encoded quoted-printable? Which I think would mean I
    need to be sure to not pass HTML with very long lines (i.e. more than
    998 characters before the newline)?

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 12:58:28AM +0200, Alexandre Cesaro wrote:
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the body to 8bit
    <https://tools.ietf.org/html/rfc2045#section-6.1> (but still encode special
    characters in headers using quoted-printable).

    Is that fine with you?

    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Actually, since I end up formatting the plain text version myself,
    I
    can
    get pretty close to what I need simply by appending ";
    format=flowed"
    to
    the contentType string of the Message receiver's SetBody function.
    (Though I don't know if that is an ideal way of going about it.)

    However, as per RFC3637, I'd like to be able to have the plain/text
    body
    (and only it) not be encoded as quoted printable. Is there a way
    to
    turn off quoted printable encoding for a given part of the mail
    message?
    Thanks,
    Braden


    On Thu, Oct 23, 2014 at 08:58:35AM -0700, braden@smashwords.com
    wrote:
    I just know I often see emails in my inbox with it, and those
    emails
    end
    up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I didn't see
    that
    mentioned in the RFC, and many of the format=flowed emails I
    receive
    are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden

    On Wednesday, October 22, 2014 11:55:19 PM UTC-7, Alexandre
    Cesaro
    wrote:
    I'm not sure: it does not seem to be a very widespread standard
    and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want and we will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the
    format=flowed
    parameter
    for text/plain content types? It seems like a nice way to
    send
    plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Alexandre Cesaro at Oct 25, 2014 at 10:35 am
    I was thinking about a line break after an already existing space. But now
    I realize that it modifies user's input too.
    So I think I will not insert any line breaks in the "unencoded" context.
    On Sat, Oct 25, 2014 at 2:28 AM, Braden Pellett wrote:

    Hi,

    I feel like maybe I am not understanding. What is a soft line break in
    the context of an 'unencoded' setting?

    Also, I wasn't able to find reference to MIME wanting a particular line
    length, except in the case of the quoted-printable encoding. At least,
    when looking at https://tools.ietf.org/html/rfc2045

    Thanks for your help!

    - Braden

    On Sat, Oct 25, 2014 at 02:19:10AM +0200, Alexandre Cesaro wrote:
    If I add the "Unencoded" setting I want it to be respectful of MIME
    specifications. That's why I want to insert soft line breaks before 78
    characters.
    But I don't want to automatically modify the user's inputs (like adding a
    space before "From" or format=flowed in the header).

    Anyway with theses changes you will be able to format your input to be f=f
    compliant.


    On Sat, Oct 25, 2014 at 1:44 AM, Braden Pellett <braden@smashwords.com>
    wrote:
    Oh, I don't think you need to concern yourself with the wrapping if it
    doesn't seem generally applicable... I already am post-processing the
    HTML part and have a wrapping method to generate the format=flowed
    plain
    text, so I could just reuse that to prevent long lines in the HTML.

    Alternatively, if you are going to do soft line breaks for long lines,
    you could perhaps just go all in and provide a format=flowed formatting
    option, :)

    I just did it like this:

    https://github.com/daBrado/tplmail/blob/master/utils.go#L57-L77

    ...for a given line at a time, anyway. Not that this is ideal... I'm
    still new to Go..!

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 01:31:24AM +0200, Alexandre Cesaro wrote:
    Yes HTML would not be encoded.

    I can also add a soft line break after the last space before 78
    characters.
    On Sat, Oct 25, 2014 at 1:16 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Yeah, I think that could work. Though, just to be clear, would
    that
    mean that in a plain and html alternative message, the text/html
    part
    would also not be encoded quoted-printable? Which I think would
    mean I
    need to be sure to not pass HTML with very long lines (i.e. more
    than
    998 characters before the newline)?

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 12:58:28AM +0200, Alexandre Cesaro wrote:
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the body to
    8bit
    encode
    special
    characters in headers using quoted-printable).

    Is that fine with you?

    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Actually, since I end up formatting the plain text version
    myself,
    I
    can
    get pretty close to what I need simply by appending ";
    format=flowed"
    to
    the contentType string of the Message receiver's SetBody
    function.
    (Though I don't know if that is an ideal way of going about
    it.)
    However, as per RFC3637, I'd like to be able to have the
    plain/text
    body
    (and only it) not be encoded as quoted printable. Is there a
    way
    to
    turn off quoted printable encoding for a given part of the mail
    message?
    Thanks,
    Braden


    On Thu, Oct 23, 2014 at 08:58:35AM -0700,
    braden@smashwords.com
    wrote:
    I just know I often see emails in my inbox with it, and those
    emails
    end
    up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I didn't
    see
    that
    mentioned in the RFC, and many of the format=flowed emails I
    receive
    are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden

    On Wednesday, October 22, 2014 11:55:19 PM UTC-7, Alexandre
    Cesaro
    wrote:
    I'm not sure: it does not seem to be a very widespread
    standard
    and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want and we
    will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the
    format=flowed
    parameter
    for text/plain content types? It seems like a nice way to
    send
    plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Braden Pellett at Oct 27, 2014 at 5:28 pm
    Okay, makes sense. Thanks!
    On Sat, Oct 25, 2014 at 12:34:11PM +0200, Alexandre Cesaro wrote:
    I was thinking about a line break after an already existing space. But now
    I realize that it modifies user's input too.
    So I think I will not insert any line breaks in the "unencoded" context.
    On Sat, Oct 25, 2014 at 2:28 AM, Braden Pellett wrote:

    Hi,

    I feel like maybe I am not understanding. What is a soft line break in
    the context of an 'unencoded' setting?

    Also, I wasn't able to find reference to MIME wanting a particular line
    length, except in the case of the quoted-printable encoding. At least,
    when looking at https://tools.ietf.org/html/rfc2045

    Thanks for your help!

    - Braden

    On Sat, Oct 25, 2014 at 02:19:10AM +0200, Alexandre Cesaro wrote:
    If I add the "Unencoded" setting I want it to be respectful of MIME
    specifications. That's why I want to insert soft line breaks before 78
    characters.
    But I don't want to automatically modify the user's inputs (like adding a
    space before "From" or format=flowed in the header).

    Anyway with theses changes you will be able to format your input to be f=f
    compliant.


    On Sat, Oct 25, 2014 at 1:44 AM, Braden Pellett <braden@smashwords.com>
    wrote:
    Oh, I don't think you need to concern yourself with the wrapping if it
    doesn't seem generally applicable... I already am post-processing the
    HTML part and have a wrapping method to generate the format=flowed
    plain
    text, so I could just reuse that to prevent long lines in the HTML.

    Alternatively, if you are going to do soft line breaks for long lines,
    you could perhaps just go all in and provide a format=flowed formatting
    option, :)

    I just did it like this:

    https://github.com/daBrado/tplmail/blob/master/utils.go#L57-L77

    ...for a given line at a time, anyway. Not that this is ideal... I'm
    still new to Go..!

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 01:31:24AM +0200, Alexandre Cesaro wrote:
    Yes HTML would not be encoded.

    I can also add a soft line break after the last space before 78
    characters.
    On Sat, Oct 25, 2014 at 1:16 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Yeah, I think that could work. Though, just to be clear, would
    that
    mean that in a plain and html alternative message, the text/html
    part
    would also not be encoded quoted-printable? Which I think would
    mean I
    need to be sure to not pass HTML with very long lines (i.e. more
    than
    998 characters before the newline)?

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 12:58:28AM +0200, Alexandre Cesaro wrote:
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the body to
    8bit
    encode
    special
    characters in headers using quoted-printable).

    Is that fine with you?

    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Actually, since I end up formatting the plain text version
    myself,
    I
    can
    get pretty close to what I need simply by appending ";
    format=flowed"
    to
    the contentType string of the Message receiver's SetBody
    function.
    (Though I don't know if that is an ideal way of going about
    it.)
    However, as per RFC3637, I'd like to be able to have the
    plain/text
    body
    (and only it) not be encoded as quoted printable. Is there a
    way
    to
    turn off quoted printable encoding for a given part of the mail
    message?
    Thanks,
    Braden


    On Thu, Oct 23, 2014 at 08:58:35AM -0700,
    braden@smashwords.com
    wrote:
    I just know I often see emails in my inbox with it, and those
    emails
    end
    up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I didn't
    see
    that
    mentioned in the RFC, and many of the format=flowed emails I
    receive
    are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden

    On Wednesday, October 22, 2014 11:55:19 PM UTC-7, Alexandre
    Cesaro
    wrote:
    I'm not sure: it does not seem to be a very widespread
    standard
    and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want and we
    will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the
    format=flowed
    parameter
    for text/plain content types? It seems like a nice way to
    send
    plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Alexandre Cesaro at Oct 28, 2014 at 7:42 am
    @Braden: I pushed the changes:
    https://github.com/go-gomail/gomail/commit/b4e3113e2dd2e703e92453e15e2161224f12e1fa

    @Peter: Thank you for your kind words!
    On Mon, Oct 27, 2014 at 6:28 PM, Braden Pellett wrote:

    Okay, makes sense. Thanks!
    On Sat, Oct 25, 2014 at 12:34:11PM +0200, Alexandre Cesaro wrote:
    I was thinking about a line break after an already existing space. But now
    I realize that it modifies user's input too.
    So I think I will not insert any line breaks in the "unencoded" context.

    On Sat, Oct 25, 2014 at 2:28 AM, Braden Pellett <braden@smashwords.com>
    wrote:
    Hi,

    I feel like maybe I am not understanding. What is a soft line break in
    the context of an 'unencoded' setting?

    Also, I wasn't able to find reference to MIME wanting a particular line
    length, except in the case of the quoted-printable encoding. At least,
    when looking at https://tools.ietf.org/html/rfc2045

    Thanks for your help!

    - Braden

    On Sat, Oct 25, 2014 at 02:19:10AM +0200, Alexandre Cesaro wrote:
    If I add the "Unencoded" setting I want it to be respectful of MIME
    specifications. That's why I want to insert soft line breaks before
    78
    characters.
    But I don't want to automatically modify the user's inputs (like
    adding a
    space before "From" or format=flowed in the header).

    Anyway with theses changes you will be able to format your input to
    be
    f=f
    compliant.


    On Sat, Oct 25, 2014 at 1:44 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Oh, I don't think you need to concern yourself with the wrapping
    if it
    doesn't seem generally applicable... I already am post-processing
    the
    HTML part and have a wrapping method to generate the format=flowed
    plain
    text, so I could just reuse that to prevent long lines in the HTML.

    Alternatively, if you are going to do soft line breaks for long
    lines,
    you could perhaps just go all in and provide a format=flowed
    formatting
    option, :)

    I just did it like this:
    https://github.com/daBrado/tplmail/blob/master/utils.go#L57-L77
    ...for a given line at a time, anyway. Not that this is ideal...
    I'm
    still new to Go..!

    Thanks,
    Braden

    On Sat, Oct 25, 2014 at 01:31:24AM +0200, Alexandre Cesaro wrote:
    Yes HTML would not be encoded.

    I can also add a soft line break after the last space before 78
    characters.
    On Sat, Oct 25, 2014 at 1:16 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Yeah, I think that could work. Though, just to be clear, would
    that
    mean that in a plain and html alternative message, the
    text/html
    part
    would also not be encoded quoted-printable? Which I think
    would
    mean I
    need to be sure to not pass HTML with very long lines (i.e.
    more
    than
    998 characters before the newline)?

    Thanks,
    Braden


    On Sat, Oct 25, 2014 at 12:58:28AM +0200, Alexandre Cesaro
    wrote:
    I can create a new Encoding
    <https://godoc.org/gopkg.in/gomail.v1#Encoding> named
    "Unencoded", so you can create your messages like that:
    msg := gomail.NewMessage(SetEncoding(gomail.Unencoded))

    It would set the Content-transfer-encoding header of the
    body to
    8bit
    encode
    special
    characters in headers using quoted-printable).

    Is that fine with you?

    On Sat, Oct 25, 2014 at 12:18 AM, Braden Pellett <
    braden@smashwords.com>
    wrote:
    Hi,

    Actually, since I end up formatting the plain text version
    myself,
    I
    can
    get pretty close to what I need simply by appending ";
    format=flowed"
    to
    the contentType string of the Message receiver's SetBody
    function.
    (Though I don't know if that is an ideal way of going about
    it.)
    However, as per RFC3637, I'd like to be able to have the
    plain/text
    body
    (and only it) not be encoded as quoted printable. Is
    there a
    way
    to
    turn off quoted printable encoding for a given part of the
    mail
    message?
    Thanks,
    Braden


    On Thu, Oct 23, 2014 at 08:58:35AM -0700,
    braden@smashwords.com
    wrote:
    I just know I often see emails in my inbox with it, and
    those
    emails
    end
    up
    formated well in Mutt. :)

    Why do you say it works only for ASCII-only text? I
    didn't
    see
    that
    mentioned in the RFC, and many of the format=flowed
    emails I
    receive
    are
    UTF-8 (charset=UTF-8).

    Anyway, sure, I'll open an issue.

    Thanks,
    Braden

    On Wednesday, October 22, 2014 11:55:19 PM UTC-7,
    Alexandre
    Cesaro
    wrote:
    I'm not sure: it does not seem to be a very widespread
    standard
    and it
    only works with ASCII-only texts.

    However you can open an issue on Github if you want
    and we
    will
    discuss it
    there.

    On Wed, Oct 22, 2014 at 11:39 PM, <
    bra...@smashwords.com
    <javascript:>>
    wrote:
    Hello,

    Thank you for the very useful package!

    I'm curious, do you have any plans to support the
    format=flowed
    parameter
    for text/plain content types? It seems like a nice
    way to
    send
    plain
    text.
    For reference:

    http://www.ietf.org/rfc/rfc3676.txt
    http://joeclark.org/ffaq.html

    I can look into implementing it, if you like.

    Thanks,
    Braden
    --
    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.
  • Braden Pellett at Oct 28, 2014 at 10:01 pm
    It is working fine for me. Thanks much!

       - Braden
    On Tue, Oct 28, 2014 at 08:41:08AM +0100, Alexandre Cesaro wrote:
    @Braden: I pushed the changes:
    https://github.com/go-gomail/gomail/commit/b4e3113e2dd2e703e92453e15e2161224f12e1fa
    --
    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.
  • Peter Digitalcrew at Oct 27, 2014 at 3:02 pm
    Thanks Alexandre - you have no idea how happy I was to discover this at the
    weekend.
    Very much appreciated.

    --
    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.
  • Umesh Veerasingam at Nov 9, 2014 at 10:43 pm
  • Jackfranzen at Jan 8, 2015 at 1:39 am
    Hello, You'll need to change the name of the "internal" package for quoted
    printable to something else for GO1.4, it seems that internal is now used
    for something else. Thanks for writing the package, it works great, and
    thank you for poaching stack overflow and answering my question about this.

    .
    --
    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.
  • Marçal Juan Llaó at Jan 11, 2015 at 9:13 pm
    Hi, I dont' know how to enable TLS encryption when creating a NewMailer,
    I'm using this:
    mailer := gomail.NewMailer("smtp.office365.com", "foo@bar.com", "password",
    587)

    I don't see any parameter on tls.Config to add for my use case...

    Thanks!

    PD: I was using PHP's SwiftMailer and this is the config I'm using: array('hostname'
    => 'smtp.office365.com', 'username' => 'foo@bar.com', 'password' => '....', 'port'
    => 587, 'encryption' => 'tls', 'timeout' => 20)

    El dijous, 8 gener de 2015 2:14:49 UTC+1, jackf...@gmail.com va escriure:
    Hello, You'll need to change the name of the "internal" package for quoted
    printable to something else for GO1.4, it seems that internal is now used
    for something else. Thanks for writing the package, it works great, and
    thank you for poaching stack overflow and answering my question about this.

    .
    --
    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.
  • Alexandre Cesaro at Jan 12, 2015 at 9:02 am
    Gomail (like net/smtp.SendMail) automatically use TLS encryption (or more
    precisely STARTTLS).
    On Sun, Jan 11, 2015 at 10:13 PM, Marçal Juan Llaó wrote:

    Hi, I dont' know how to enable TLS encryption when creating a NewMailer,
    I'm using this:
    mailer := gomail.NewMailer("smtp.office365.com", "foo@bar.com",
    "password", 587)

    I don't see any parameter on tls.Config to add for my use case...

    Thanks!

    PD: I was using PHP's SwiftMailer and this is the config I'm using: array('hostname'
    => 'smtp.office365.com', 'username' => 'foo@bar.com', 'password' => '....',
    'port' => 587, 'encryption' => 'tls', 'timeout' => 20)

    El dijous, 8 gener de 2015 2:14:49 UTC+1, jackf...@gmail.com va escriure:
    Hello, You'll need to change the name of the "internal" package for
    quoted printable to something else for GO1.4, it seems that internal is now
    used for something else. Thanks for writing the package, it works great,
    and thank you for poaching stack overflow and answering my question about
    this.

    .
    --
    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.
  • Marçal Juan Llaó at Jan 12, 2015 at 4:29 pm
    It throws me this error: "504 5.7.4 Unrecognized authentication type"

    With PHP is working fine :/

    El Mon Jan 12 2015 at 10:02:40 AM, Alexandre Cesaro (<
    alexandre.cesaro@gmail.com>) va escriure:
    Gomail (like net/smtp.SendMail) automatically use TLS encryption (or more
    precisely STARTTLS).
    On Sun, Jan 11, 2015 at 10:13 PM, Marçal Juan Llaó wrote:

    Hi, I dont' know how to enable TLS encryption when creating a NewMailer,
    I'm using this:
    mailer := gomail.NewMailer("smtp.office365.com", "foo@bar.com",
    "password", 587)

    I don't see any parameter on tls.Config to add for my use case...

    Thanks!

    PD: I was using PHP's SwiftMailer and this is the config I'm using: array
    ('hostname' => 'smtp.office365.com', 'username' => 'foo@bar.com', 'password'
    => '....', 'port' => 587, 'encryption' => 'tls', 'timeout' => 20)

    El dijous, 8 gener de 2015 2:14:49 UTC+1, jackf...@gmail.com va escriure:
    Hello, You'll need to change the name of the "internal" package for
    quoted printable to something else for GO1.4, it seems that internal is now
    used for something else. Thanks for writing the package, it works great,
    and thank you for poaching stack overflow and answering my question about
    this.

    .
    --
    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.
  • Alexandre Cesaro at Jan 12, 2015 at 1:03 pm
    I created an issue on Github and gave an answer there:
    https://github.com/go-gomail/gomail/issues/16
    On Mon, Jan 12, 2015 at 1:13 PM, Marçal Juan Llaó wrote:

    It throws me this error: "504 5.7.4 Unrecognized authentication type"

    With PHP is working fine :/

    El Mon Jan 12 2015 at 10:02:40 AM, Alexandre Cesaro (<
    alexandre.cesaro@gmail.com>) va escriure:

    Gomail (like net/smtp.SendMail) automatically use TLS encryption (or more
    precisely STARTTLS).

    On Sun, Jan 11, 2015 at 10:13 PM, Marçal Juan Llaó <marcalj@gmail.com>
    wrote:
    Hi, I dont' know how to enable TLS encryption when creating a NewMailer,
    I'm using this:
    mailer := gomail.NewMailer("smtp.office365.com", "foo@bar.com",
    "password", 587)

    I don't see any parameter on tls.Config to add for my use case...

    Thanks!

    PD: I was using PHP's SwiftMailer and this is the config I'm using:
    array('hostname' => 'smtp.office365.com', 'username' => 'foo@bar.com', 'password'
    => '....', 'port' => 587, 'encryption' => 'tls', 'timeout' => 20)

    El dijous, 8 gener de 2015 2:14:49 UTC+1, jackf...@gmail.com va
    escriure:
    Hello, You'll need to change the name of the "internal" package for
    quoted printable to something else for GO1.4, it seems that internal is now
    used for something else. Thanks for writing the package, it works great,
    and thank you for poaching stack overflow and answering my question about
    this.

    .
    --
    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.
  • Nguyenkimryan1990 at Apr 21, 2015 at 3:16 pm
    Hi friend,
    I'm facing this error when using your library:

    panic: mail: missing phrase

    Can you help?

    --
    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.
  • Alexandre Cesaro at Apr 21, 2015 at 9:52 am
    Can you show your code?
    On Tue, Apr 21, 2015 at 11:42 AM, wrote:

    Hi friend,
    I'm facing this error when using your library:

    panic: mail: missing phrase

    Can you help?
    --
    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.
  • Nguyenkimryan1990 at Apr 22, 2015 at 4:17 am
    The issue is solved, I have a chat with you on google hangout. Thanks for
    your work!

    Vào 16:52:58 UTC+7 Thứ Ba, ngày 21 tháng 4 năm 2015, Alexandre Cesaro đã
    viết:
    Can you show your code?

    On Tue, Apr 21, 2015 at 11:42 AM, <nguyenki...@gmail.com <javascript:>>
    wrote:
    Hi friend,
    I'm facing this error when using your library:

    panic: mail: missing phrase

    Can you help?
    --
    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
postedJun 26, '14 at 4:26p
activeApr 22, '15 at 4:17a
posts32
users12
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase