The mail() function returns a value of True (My web server)

The mail() function returns a value of True if it is successful and False if it fails. You can use this function to make your application a little more robust: $mailsent = mail($to, $subject, $message, $headers); if ($mailsent) { echo Congrats! The following message has been sent:

; echo To: $to
; echo From: $from
; echo Subject: $subject

; echo Message:
; echo $message; } else { echo There was an error… ; } ?> Of course, you can modify this to handle errors more elegantly. Use the knowledge you acquired in Chapter 9 to do so. You have now created your first PHP e-mail application. Congratulations! (Call your mother! She ll be so proud.) But you ll probably soon get tired of ugly, plain-text e-mails. I m sure you re champing at the bit to create colorful, formatted e-mails, right? How else are you going to enable users to send some pretty postcards? Okay, let s do something about that! Dressing Up Your E-mails with HTML Because you are creating a postcard application, sending plain-text e-mails just won t do. You want to dress them up a bit, and make them look professional, yet attractive. So, add a bit of HTML to your e-mail code to dress it up. Try It Out Sending HTML Code in an E-mail First, let s try a little experiment. This step isn t vital, but it will help illustrate a later point about headers. 1. Go to step 5 of the previous Try It Out section and send another e-mail. This time, put some HTML in the message. An example would be:

Hello World!

Prepare for our arrival.

We are starving!!! 2. When you have entered all relevant data in the form, click the Send button, and check your e-mail. It should look something like the e-mail shown in Figure 11-4. 331 Sending E-mail
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply