send alert
This commit is contained in:
		
							
								
								
									
										12
									
								
								emails.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								emails.go
									
									
									
									
									
								
							| @@ -152,3 +152,15 @@ func SendMail(addr, from, subject, body string, to string) error { | ||||
| 	} | ||||
| 	return c.Quit() | ||||
| } | ||||
|  | ||||
| func SendAlert(u int64, subject, body string) error { | ||||
| 	user, ok := GetById(u) | ||||
| 	if !ok { | ||||
| 		return fmt.Errorf("scsusers.SendAlert: User %d not found", u) | ||||
| 	} | ||||
| 	email, ok := user.Get("email") | ||||
| 	if !ok { | ||||
| 		return fmt.Errorf("scsusers.SendAlert: User %d has no email", u) | ||||
| 	} | ||||
| 	return SendMail(c.SMTPServer, c.FromEmail, subject, body, email) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user