Archive for November, 2007

5. Load up (Web hosting bandwidth) the first page, postcard.php, in

Monday, November 5th, 2007

5. Load up the first page, postcard.php, in your browser, and enter some data. Make sure you use a valid e-mail address so that you can verify their receipt. It should look something like Figure 11-1. Figure 11-1 6. Click the Send button. A second page appears, similar to the one shown in Figure 11-2. Figure 11-2 329 Sending E-mail
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Free web hosting music - Enter your message here 2. Save the page

Sunday, November 4th, 2007

2. Save the page as postcard.php. Note that postcard.php doesn t actually have any PHP code in it. It simply collects the required data in an HTML form. You re giving it a .php extension in case you decide to add PHP code to it later (and you will). 3. Start a new text document and enter the following code:

; echo To: $to
; echo From: $from
; echo Subject: $subject
; echo Message:
; echo $message; } else { echo There was an error… ; } ?> 4. Save this page as sendmail.php. This second page will take the values entered into the first page and send them in an e-mail. 328 Chapter 11
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

How It Works Pretty cool, huh? That s (Web hosting asp) all

Saturday, November 3rd, 2007

How It Works Pretty cool, huh? That s all there is to it! The mail() function automatically sends an e-mail, using the following format: Mail(to, subject, message, headers, other_parameters) The parameters headers and other_parameters are optional. If you want to send a message to multiple recipients, their addresses must be separated with a comma in the to parameter: Mail( first@e-mail.com, second@e-mail.com , Hi , Whazzup?? ) We will cover the headers parameter soon. The other_parameters are beyond the scope of this book, but if you want more information about the mail() function, point your browser to www.php.net/ manual/en/function.mail.php. You may have noticed when receiving this e-mail that there was no From address (or, your service provider may have automatically put in a bogus address). Ours says Nobody. In the next example, you ll see how to add a From: parameter to your e-mail, and you ll collect information from the user before sending the e-mail. Let s dig in! Try It Out Collecting Data and Sending an E-mail In this exercise, you are going to create two Web pages, postcard.php and sendmail.php. The file postcard.php will collect the data you are going to send. The file sendmail.php will actually send the message, using the data you enter. 1. Start up your favorite text/PHP/HTML editor, and enter the following code:

To:
From:
Subject:
Message: 327 Sending E-mail
We recommend high quality webhost to host and run your jsp application: christian web host services.

Web design service - If you are in a UNIX or Linux

Friday, November 2nd, 2007

If you are in a UNIX or Linux environment, you will most likely have sendmail installed on your server. If you are using a hosting service, check with your service provider to make sure sendmail or some equivalent is being used. If you are not using sendmail, or you have Apache installed on a Windows server, you have a couple of choices. You can use your existing SMTP (Simple Mail Transport Protocol) service, or you can install a mail server such as Mailtraq on your computer. If you have questions or concerns about setting up or using a mail server, many online resources are available to help you. We suggest using a search engine. Once you have your mail server squared away, you ll need to modify your php.ini file. There are a couple of parameters you need to set. Of course, if you are using a hosting service, the host should already have these parameters set up. . SMTP: Set this to the IP address or DNS name of your SMTP server. For example, if you have a mail server installed on the same server as your PHP server, you should be able to set SMTP to localhost. This applies to Windows installations only. . smtp_port: Set this to the port PHP uses to connect to the SMTP server. This applies to Windows installations only and is valid for PHP version 4.3 and above. . sendmail_from: The From address used by default by the PHP mail() command. . sendmail_path: The path to the sendmail program (UNIX/Linux servers only). For most servers, this is usr/sbin/sendmail. That s just about all there is to setting up PHP for e-mail. You will test to make sure it works correctly in the next section, Sending an E-mail. You can find more information about setting up PHP for mail at http://us3.php.net/manual/en/ref.mail.php. Sending an E-mail The actual method of sending an e-mail is quite simple. Of course, it can be made much more complex with the addition of headers, and sending HTML and images. However, you are going to start off with something simple. Try It Out Sending a Simple E-mail This example is just about the simplest code you can write to send an e-mail. Of course, it s not very flexible, but it does demonstrate the mail() function quite well. 1. Start your favorite text/PHP/HTML editor. 2. Enter the following code. Make sure you put your own e-mail address in as the first parameter: 3. Save the text file as firstmail.php and load it in your browser. You should see a blank page and should receive an e-mail shortly at the address entered as the first parameter. 326 Chapter 11
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Best web design - 11 Sending E-mail So far, the chapters in

Thursday, November 1st, 2007

11 Sending E-mail So far, the chapters in this book have walked you through the creation of a comprehensive Web site. You have designed your site so that users can add and modify data, which is being stored in databases. You have built pages dynamically for your users, ensuring they have a rich and unique experience when they visit your Web site. You are even displaying helpful error messages in case something goes wrong. Now it s time to get a little more interactive with your users with e-mail. But we are not talking about standard e-mail, in which you write to your mother to tell her about the cool site you ve been building. (You did tell her, didn t you? She would be so proud.) We re talking about sending out e-mails using PHP. Why would you want a server-side scripting language to send e-mails? Perhaps you want to create a simple feedback form to be submitted to an administrator, as introduced in Chapter 9. Or maybe you want certain errors to be automatically e-mailed to the Webmaster. Or perhaps you would like to create an application that allows users to send their friends and family electronic postcards. (Nod your head in vigorous agreement here because that is exactly what you are going to do!) Specifically, this chapter covers: . Sending a basic e-mail . Sending an e-mail formatted with HTML . Multipart messages . Sending images . Getting confirmation Setting Up PHP to Use E-mail To be able to send e-mail with PHP, you need an e-mail server. This chapter doesn t delve too deeply into the setup of a mail server for PHP, but here are the basics.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.