Пример #1
0
				Subject: "Super Urgent! Read Now!",
				Body: []mail.Part{
					{
						ContentType: "text/plain",
						Content:     "Banana",
					},
					{
						ContentType: "text/html",
						Content:     "<header>banana</header>",
					},
				},
			}
		})

		It("returns a populated data mail field as a string", func() {
			parts := strings.Split(msg.Data(), "\n")
			boundary := msg.Boundary()

			Expect(parts).To(ConsistOf([]string{
				"From: [email protected]",
				"To: [email protected]",
				"Subject: Super Urgent! Read Now!",
				"Content-Type: multipart/alternative; boundary=" + boundary,
				"Date: " + time.Now().Format(time.RFC822Z),
				"Mime-Version: 1.0",
				"",
				"--" + boundary,
				"Content-Type: text/plain; charset=UTF-8",
				"Content-Transfer-Encoding: quoted-printable",
				"",
				"Banana",
Пример #2
0
				},
			}

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

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

			Expect(delivery.Sender).To(Equal("*****@*****.**"))
			Expect(delivery.Recipient).To(Equal("*****@*****.**"))
			Expect(delivery.Data).To(Equal(strings.Split(msg.Data(), "\n")))
			Expect(delivery.UsedTLS).To(BeTrue())
		})

		It("can make multiple requests", func() {
			firstMsg := 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!",
					},
				},
			}