mailgun/mailgun-go

Allow to use : in domain for testing

ivaaaan opened this issue · 2 comments

Hey. I'm trying to write a test using a mailgun mock server:

mailgunServer := mailgun.NewMockServer()
mailgunClient := mailgun.NewMailgun(mailgunServer.URL(), "")

However, I'm getting an error from this place:

https://github.com/mailgun/mailgun-go/blob/master/messages.go#L557:

invalidChars := ":&'@(),!?#;%+=<>"
if i := strings.ContainsAny(mg.domain, invalidChars); i {
    err = fmt.Errorf("you called Send() with a domain that contains invalid characters")
    return
}

Can we allow : in the domain for testing purposes? I can create a PR if needed

Sorry for the late reply, but yes, I think that is appropriate change to make.

Hi @ivaaaan This issue was brought to my attention again. What you actually want is this mg.SetAPIBase(server.URL()) passing the URL as the domain is not appropriate here.