Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHORE add unittest for funtion Send for cover test coverage #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions email_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,3 +931,24 @@ func TestParseSender(t *testing.T) {
}
}
}

func TestSendEmail(t *testing.T) {
input := &Email{
From: "example_from@gmail.com",
To: []string{"example_to@gmail.com"},
Subject: "Test Subject",
Text: []byte("This is a test email with HTML Formatting. It also has very long lines so\nthat the content must be wrapped if using quoted-printable decoding.\n"),
HTML: []byte("<div dir=\"ltr\">This is a test email with <b>HTML Formatting.</b>\u00a0It also has very long lines so that the content must be wrapped if using quoted-printable decoding.</div>\n"),
}

err := input.Send("smtp.gmail.com:587", smtp.PlainAuth("", input.From, "password123", "smtp.gmail.com"))
if err == nil {
t.Fatalf("Error expected when sending email")
}

err = input.Send("smtp.gmail.com:587", smtp.PlainAuth("", input.From, "password123", "smtp.gmail.com"))
if err == nil {
t.Fatalf("Error expected when sending email")
}

}