Re: Looking for easier way to build email message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 24, 2008 6:20 PM, Rene Brehmer <rene@xxxxxxxxxxxxxx> wrote:

> Drew a blank off the archive, so here goes...
>
> I'm working on some forms for our company website, all of which simply
> have
> to be mailed to us by email.
>
> After verifying that the content of all the fields is valid and the proper
> type, it builds the email message as following. This all works great, but
> I
> want a simpler/easier way to reuse the code (we have 3 forms, with
> distinctively different content, but the mail process remains the same),
> so
> something that will do the below, but can be reduced to something like
> grabbing a text file and fill in the blanks would be nice, instead of
> this:
>
>  // prepare message
>  if(! $error) {
>    $message = "Information submitted with Tee Time booking form:\r\n";
>    $message .= "Name and address:\r\n\r\n";
>    $message .= "$name\r\n";
>    $message .= "$address\r\n";
>    $message .= "$city\r\n";
>    $message .= "$state $postcode\r\n\r\n";
>    $message .= "Email: $email\r\n";
>    $message .= "Phone: $phone\r\n";
>    $message .= "\r\n\r\nBooking info:\r\n\r\n";
>    $message .= "Arrival: $a_month $a_day\r\n";
>    $message .= "Departure: $d_month $d_day\r\n";
>    $message .= "Persons: $persons\r\n";
>    $message .= "Rooms: $rooms\r\n";
>    $message .= "\r\nGolf Courses\r\n\r\n";
>    for($i = 1; $i < 8; $i++) {
>      if($_POST['course_'.$i] != 0) {
>        $message .= 'Course: '.$_POST['course_'.$i]."\r\n";
>        $message .= 'Date: '.$_POST['month_'.$i].'
> '.$_POST['day_'.$i]."\r\n";
>        $message .= 'Time: '.$_POST['teetime_'.$i]."\r\n";
>        $message .= '# of golfers: '.$_POST['golfers_'.$i]."\r\n";
>      }
>    }
>    if(! empty($comments)) {
>      $message .= "\r\nComments:\r\n$comments\r\n";
>    }
>    $message .= "\r\nUser Client Info:\r\n";
>    $message .= 'User IP: '.$_SERVER['REMOTE_ADDR']."\r\nUser agent:
> ".$_SERVER['HTTP_USER_AGENT']."\r\n\r\n";
>
>
> // NOTE: This code only builds the actual message, the headers are built
> elsewhere in the code.
> // This is our golf-package quote request (I work for a hotel) form, where
> you can book up to 7 tee times. Thus the iteration in the middle, to run
> through the 7 tee time fields.


check the  archives for smtp vs. mail(); somebody mentioned a number of
classes available at this site:
http://www.phpclasses.org

some of them looked quite useful.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux