2
0

api_func_email.go 723 B

1234567891011121314151617181920212223242526272829
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. )
  5. func Api_func_email_post(config tool.Config) string {
  6. db := tool.DB_connect()
  7. defer tool.DB_close(db)
  8. other_set := map[string]string{}
  9. json.Unmarshal([]byte(config.Other_set), &other_set)
  10. err := tool.Send_email(db, config.IP, other_set["who"], other_set["title"], other_set["data"])
  11. if err == nil {
  12. new_data := make(map[string]any)
  13. new_data["response"] = "ok"
  14. json_data, _ := json.Marshal(new_data)
  15. return string(json_data)
  16. }
  17. new_data := make(map[string]any)
  18. new_data["response"] = "err"
  19. new_data["data"] = err.Error()
  20. json_data, _ := json.Marshal(new_data)
  21. return string(json_data)
  22. }