go-gomail / gomail

The best way to send emails in Go.
MIT License
4.37k stars 577 forks source link

anonymous relay #32

Closed guybrand closed 9 years ago

guybrand commented 9 years ago

Hi .

I am trying to relay on a server with no authentication . using a telnet client , I can simply :

  1. telnet MyServer MyPort
  2. Helo
  3. MAIL FROM: me@gmail.com
  4. RCPT TO: you@gmail.com
  5. SUBJECT:how are you?
  6. period (.)

I tried to create an Auth with Start function that returns immediately , with empty return value , or "MAIL FROM:" , but I guess no matter what I do , smtp package will go through : code, msg64, err := c.cmd(0, "AUTH %s %s", mech, resp64) that the server will decline .

Do you have an idea for doing anonymous connection/ESMTP AUTH . my best help so far was http://www.fehcom.de/qmail/smtpauth.html

Thanks .

alexcesaro commented 9 years ago

Have you tried using NewCustomMailer with a nil Auth?

guybrand commented 9 years ago

Nop , same error L

x509: certificate signed by unknown authority

From: Alexandre Cesaro [mailto:notifications@github.com] Sent: Monday, April 20, 2015 5:05 PM To: go-gomail/gomail Cc: GuyBrand Subject: Re: [gomail] anonymous relay (#32)

Have you tried using NewCustomMailer with a nil Auth?

— Reply to this email directly or view https://github.com/go-gomail/gomail/issues/32#issuecomment-94460495 it on GitHub. https://github.com/notifications/beacon/AFpMciLdbwlqAS1tpiOPLXzItXYJcoiUks5oBP8IgaJpZM4EDwcF.gif

alexcesaro commented 9 years ago

Have you tried what's in the readme? https://github.com/go-gomail/gomail#x509-certificate-signed-by-unknown-authority

guybrand commented 9 years ago

Yes , no help there .

Notice that if I use NewMailer , I must empty the UN/PW

mailer := gomail.NewMailer("mysmtp.net", "", "", 25, gomail.SetTLSConfig(&tls.Config{InsecureSkipVerify: true}))

guy .

From: Alexandre Cesaro [mailto:notifications@github.com] Sent: Monday, April 20, 2015 5:21 PM To: go-gomail/gomail Cc: GuyBrand Subject: Re: [gomail] anonymous relay (#32)

Have you tried what's in the readme? https://github.com/go-gomail/gomail#x509-certificate-signed-by-unknown-authority

— Reply to this email directly or view https://github.com/go-gomail/gomail/issues/32#issuecomment-94465689 it on GitHub. https://github.com/notifications/beacon/AFpMcisyDC9H44CYy-wPqLFtLsnx_ffeks5oBQLNgaJpZM4EDwcF.gif

alexcesaro commented 9 years ago

What is the error in this case?

You should try using both NewCustomMailer with nil Auth and SetTLSConfig.

guybrand commented 9 years ago

Both return same error :

x509: certificate signed by unknown authority

From: Alexandre Cesaro [mailto:notifications@github.com] Sent: Monday, April 20, 2015 6:26 PM To: go-gomail/gomail Cc: GuyBrand Subject: Re: [gomail] anonymous relay (#32)

What is the error in this case?

You should try using both NewCustomMailer with nil Auth and SetTLSConfig.

— Reply to this email directly or view https://github.com/go-gomail/gomail/issues/32#issuecomment-94483243 it on GitHub. https://github.com/notifications/beacon/AFpMcrkFVxhOqFwcNnITfiqJvLIvGHgWks5oBRIOgaJpZM4EDwcF.gif

guybrand commented 9 years ago

Hi .

The Client's IT has sent me a CERT file thinking it may solve the situation . I dont know if it has anything to do with it , but now , when I : mailer := gomail.NewMailer("serverIp", "", "", 25, gomail.SetTLSConfig(&tls.Config{InsecureSkipVerify: true})) I get the error : 504 5.7.4 Unrecognized authentication type same if I put something in the UN/PW

guybrand commented 9 years ago

Good news ! and a question

the news : I've figured it out : I use the simple : mailer := gomail.NewMailer("serverIp", "", "", 25)

  1. on starttlsDial , I comment the
    //if ok, _ := c.Extension("STARTTLS"); ok { // fmt.Println("STARTTLS", err) // return c, c.StartTLS(config) //} cause you dont need TLS in this case .
  2. on getSendMailFunc , I remarked : //if a != nil { // fmt.Println("a!=nil ", err) // if ok, _ := c.Extension("AUTH"); ok { // if err = c.Auth(a); err != nil { // return err // } // } //}

and I have an anonymous relay working .

question is : would you like to implant that in a nicer way on your code , so it will support whatever it does now , as well as the anonymous relay ?

Guy .

alexcesaro commented 9 years ago

Ok I will have a look.

alexcesaro commented 9 years ago

Hello, it would be cool if you tried Gomail v2 (still unstable) and tell me if it works:

package main

import (
    "gopkg.in/gomail.v2-unstable"
)

func main() {
    m := gomail.NewMessage()
    m.SetHeader("From", "from@example.com")
    m.SetHeader("To", "to@example.com")
    m.SetHeader("Subject", "Test")
    m.SetBody("text/html", "Test")

    d := &gomail.Dialer{Host: "smtp.example.org", Port: 587}
    if err := d.DialAndSend(m); err != nil {
        panic(err)
    }
}
alexcesaro commented 9 years ago

I just edited my previous answer.

guybrand commented 9 years ago

Hi .

I'm off to a weekend , will do that early next week .

Thanks !

BTW , the current "workaround" is already in production .

From: Alexandre Cesaro [mailto:notifications@github.com] Sent: Thursday, July 16, 2015 11:42 PM To: go-gomail/gomail Cc: GuyBrand Subject: Re: [gomail] anonymous relay (#32)

Hello, it would be cool if you tried Gomail v2 (still unstable) and tell me if it works:

package main

import ( "gopkg.in/gomail.v2-unstable" )

func main() { m := gomail.NewMessage() m.SetHeader("From", "from@example.com") m.SetHeader("To", "to@example.com") m.SetHeader("Subject", "Test") m.SetBody("text/html", "Test")

d := gomail.NewPlainDialer("smtp.example.com", "user", "123456", 587)
d.Auth = nil
if err := d.DialAndSend(m); err != nil {
    panic(err)
}

}

— Reply to this email directly or view https://github.com/go-gomail/gomail/issues/32#issuecomment-122086189 it on GitHub. https://github.com/notifications/beacon/AFpMciMmm80QIXY2Z0ODM6WRq1LNozxPks5oeA6ZgaJpZM4EDwcF.gif