Пример #1
0
// Send a raw MIME message.
func (a *API) raw(r *http.Request) interface{} {
	var raw email.Raw
	if err := json.NewDecoder(r.Body).Decode(&raw); err != nil {
		return err
	}
	if err := raw.DeliverToQueue(a.queue); err != nil {
		return err
	}
	return struct{}{}
}
Пример #2
0
// run continuously delivers
func (s *Server) run() {
	for m := range s.server.NewMessage {
		s.log.Info("email received via SMTP")
		raw := email.Raw{
			From: m.From,
			To:   m.To,
			Body: m.Body,
		}
		if err := raw.DeliverToQueue(s.queue); err != nil {
			s.log.Error(err.Error())
		}
	}
}