Once an order has been processed, the winestore application confirms the shipping of the wines through both an email and an HTML receipt. The order.3 script redirects to the shipping.1 script shown in Example 12-2, which sends the user an email. In turn, the shipping.1 script redirects to the shipping.2 script shown in Example 12-3, which produces the HTML receipt. The HTML receipt can be visited again at a later time by bookmarking the URL and, as it carries out no database updates, it doesn’t suffer from the reload problem described in Chapter 6. The receipt functionality is separated into two scripts so that returning to the HTML receipt doesn’t cause an additional email receipt to be sent to the customer.
in Example 12-2 creates the
destination address, the subject, the body, and additional headers of
an email message, and then sends that email message. The destination
to address is created using the
surname, and the
Michael Smith <email@example.com>
The additional email headers are static and always have the following format:
From: "Hugh and Dave's Online Wines" <firstname.lastname@example.org> X-Sender: <email@example.com> X-Mailer: PHP X-Priority: 1 Return-Path: <firstname.lastname@example.org>
The subject of the email is always:
$subject = "Hugh and Dave's Online Wines: Order Confirmation";
The body of the message ...