parent
							
								
									2ef05a20d5
								
							
						
					
					
						commit
						b61c2a7e3a
					
				| 
						 | 
				
			
			@ -118,6 +118,7 @@ type Config struct {
 | 
			
		|||
		Port     string
 | 
			
		||||
		Username string
 | 
			
		||||
		Password string
 | 
			
		||||
		From     string
 | 
			
		||||
 | 
			
		||||
		CertLimit int
 | 
			
		||||
		NagTimes  []string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -247,7 +247,7 @@ func main() {
 | 
			
		|||
		tmpl, err := template.New("expiry-email").Parse(string(emailTmpl))
 | 
			
		||||
		cmd.FailOnError(err, "Could not parse email template")
 | 
			
		||||
 | 
			
		||||
		mailClient := mail.New(c.Mailer.Server, c.Mailer.Port, c.Mailer.Username, c.Mailer.Password)
 | 
			
		||||
		mailClient := mail.New(c.Mailer.Server, c.Mailer.Port, c.Mailer.Username, c.Mailer.Password, c.Mailer.From)
 | 
			
		||||
 | 
			
		||||
		nagCheckInterval := defaultNagCheckInterval
 | 
			
		||||
		if s := c.Mailer.NagCheckInterval; s != "" {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -64,13 +64,13 @@ func isASCII(str string) bool {
 | 
			
		|||
 | 
			
		||||
// New constructs a Mailer to represent an account on a particular mail
 | 
			
		||||
// transfer agent.
 | 
			
		||||
func New(server, port, username, password string) MailerImpl {
 | 
			
		||||
func New(server, port, username, password, from string) MailerImpl {
 | 
			
		||||
	auth := smtp.PlainAuth("", username, password, server)
 | 
			
		||||
	return MailerImpl{
 | 
			
		||||
		Server:      server,
 | 
			
		||||
		Port:        port,
 | 
			
		||||
		Auth:        auth,
 | 
			
		||||
		From:        username,
 | 
			
		||||
		From:        from,
 | 
			
		||||
		clk:         clock.Default(),
 | 
			
		||||
		csprgSource: realSource{},
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,9 @@ func (f fakeSource) generate() *big.Int {
 | 
			
		|||
 | 
			
		||||
func TestGenerateMessage(t *testing.T) {
 | 
			
		||||
	fc := clock.NewFake()
 | 
			
		||||
	m := MailerImpl{From: "send@email.com", clk: fc, csprgSource: fakeSource{}}
 | 
			
		||||
	m := New("", "", "", "", "send@email.com")
 | 
			
		||||
	m.clk = fc
 | 
			
		||||
	m.csprgSource = fakeSource{}
 | 
			
		||||
	messageBytes, err := m.generateMessage([]string{"recv@email.com"}, "test subject", "this is the body\n")
 | 
			
		||||
	test.AssertNotError(t, err, "Failed to generate email body")
 | 
			
		||||
	message := string(messageBytes)
 | 
			
		||||
| 
						 | 
				
			
			@ -44,8 +46,7 @@ func TestGenerateMessage(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestFailNonASCIIAddress(t *testing.T) {
 | 
			
		||||
	fc := clock.NewFake()
 | 
			
		||||
	m := MailerImpl{From: "send@email.com", clk: fc, csprgSource: fakeSource{}}
 | 
			
		||||
	m := New("", "", "", "", "send@email.com")
 | 
			
		||||
	_, err := m.generateMessage([]string{"遗憾@email.com"}, "test subject", "this is the body\n")
 | 
			
		||||
	test.AssertError(t, err, "Allowed a non-ASCII to address incorrectly")
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue