Skip to content

Commit

Permalink
sending email
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomog committed Dec 11, 2023
1 parent 55941b0 commit 23c3ca2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ func (m *Repository) PostReservation(w http.ResponseWriter, r *http.Request) {
return
}

// send notifications - to gest

htmlMessage := fmt.Sprintf(`
<strong>Reservation Confirmation</strong>
Dear %s, <br>
This is confirm your reservation from %s to %s.
`, reservation.FirstName , reservation.StartDate.Format("2006-01-01"), reservation.EndDate.Format("2006-01-01"))

msg := models.MailData{
To: reservation.Email,
From: "test@server.com",
Subject: "Reservation Confirmation",
Content: htmlMessage,
}

m.App.MailChan <- msg

m.App.Session.Put(r.Context(), "reservation", reservation)
http.Redirect(w, r, "/reservation-summary", http.StatusSeeOther)
}
Expand Down
2 changes: 2 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ go build -o bookings cmd/web/*.go && ./bookings
# sudo service postgresql status
# sudo -u postgres psql
# install soda brew install gobuffalo/tap/pop
# 802
# ~/go/bin/MailHog

0 comments on commit 23c3ca2

Please sign in to comment.