示例#1
0
func FreshTestMail(provider mtacontainer.MTAProvider, to string) model.Email {

	var headers map[string][]string = map[string][]string{
		"To":      []string{to},
		"From":    []string{"BitMail <*****@*****.**>"},
		"Subject": []string{"An Email test through " + provider.GetName()},
	}

	var content = "Hi, this is a test, sincerely the BitMail team."
	return model.NewMail(content, headers)
}
func ManuallyVerifyEmailSend(provider mtacontainer.MTAProvider, to string) {

	//
	// Output all events from MTA Provider
	//
	c := make(chan int)
	go func() {
		for {
			select {
			case <-c:
				return
			case e := <-provider.GetEvent():
				println(e.GetError().Error())
			}
		}
	}()

	// Send verification email
	mail := model.NewMailSimpleHeaders("Test\nTest\nTest",
		map[string]string{
			"To":      to,
			"From":    "*****@*****.**",
			"Subject": "Test email"})

	provider.GetOutgoing() <- mail

	// wait for manual verification.
	line := goh.ReadLine("Did your receive an e-mail with subject \"" + mail.GetHeaders()["Subject"][0] +
		"\" at " + to + " [y/n]?")

	ok := strings.Compare("y", line) == 0

	if ok == false {
		println("Manually Verify Email Send Failed.")
	} else {
		println("Yes mail successfully sent :-)")
	}

}