29 lines
877 B
Go
29 lines
877 B
Go
package smtpclient_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"fiskerinc.com/modules/smtpclient"
|
|
"fiskerinc.com/modules/testhelper"
|
|
)
|
|
|
|
func TestSMTP(t *testing.T) {
|
|
testEmails := []string{"test@fiskerinc.com"}
|
|
expected := "535 Authentication Credentials Invalid"
|
|
host := "email-smtp.us-west-2.amazonaws.com"
|
|
smtp := smtpclient.NewSMTP(host, 587)
|
|
defer smtp.Close()
|
|
err := smtp.Send(smtpclient.FromEmail, testEmails, "test", "this is a test")
|
|
if err != smtpclient.ErrAuthRequired {
|
|
t.Errorf(testhelper.TestErrorTemplate, "No auth", smtpclient.ErrAuthRequired, err)
|
|
}
|
|
|
|
smtp.Auth("fakeuser", "fakepassword")
|
|
err = smtp.Send(smtpclient.FromEmail, testEmails, "test", "this is a test")
|
|
if err == nil {
|
|
t.Errorf(testhelper.TestErrorTemplate, "auth error", "error", err)
|
|
} else if err.Error() != expected {
|
|
t.Errorf(testhelper.TestErrorTemplate, "auth error", expected, err)
|
|
}
|
|
}
|