Пример #1
0
package mail_test

import (
	"strings"
	"time"

	"github.com/cloudfoundry-incubator/notifications/mail"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Message", func() {
	Describe("Data", func() {
		var msg mail.Message

		BeforeEach(func() {
			msg = mail.Message{
				From:    "*****@*****.**",
				To:      "*****@*****.**",
				Subject: "Super Urgent! Read Now!",
				Body: []mail.Part{
					{
						ContentType: "text/plain",
						Content:     "Banana",
					},
					{
						ContentType: "text/html",
						Content:     "<header>banana</header>",
					},
				},
Пример #2
0
			mailServer.SupportsTLS = true
			config.Host, config.Port, err = net.SplitHostPort(mailServer.URL.String())
			if err != nil {
				panic(err)
			}
			client = mail.NewClient(config)
		})

		It("can send mail", func() {
			msg := mail.Message{
				From:    "*****@*****.**",
				To:      "*****@*****.**",
				Subject: "Urgent! Read now!",
				Body: []mail.Part{
					{
						ContentType: "text/plain",
						Content:     "This email is the most important thing you will read all day%40!",
					},
				},
			}

			err := client.Send(msg, logger)
			if err != nil {
				panic(err)
			}

			Eventually(func() int {
				return len(mailServer.Deliveries)
			}).Should(Equal(1))
			delivery := mailServer.Deliveries[0]