Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML mail problem

    Hi,

    As far as i can tell (but I'm an absolute PHP noob, and sorry for that) I'm having the same kind of problems as described in this topic…. Having found a similar problem is as far as I can get. I need someone to change the script for me, to get it right. I'm well willing to pay if that's an issue.

    This is the code ‘the event booking calendar’ script uses, which needs to be modified, to receive the mail in HTML but I’m clueless where and how

    PHP Code:
    <?php
        
    include("options.php");
        include(
    "include/functions.php");
        
        if(
    $_REQUEST["ac"]=="book"){
            
            
    $sql "SELECT * FROM ".$TABLES["CALENDARS"]." WHERE id='".$_REQUEST["cid"]."'";
            
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
            
    $Calendar mysql_fetch_assoc($sql_result);
            
    $CalendarOptions unserialize($Calendar["options"]);
            
    $timeFormat $CalendarOptions["timeFormat"];

            
    $sql "SELECT * FROM ".$TABLES["EVENTS"]." WHERE id = '".$_REQUEST["eid"]."'";
            
    $sql_result mysql_query ($sql$connection) or die ('request "Could not execute SQL query" '.$sql);
            
    $Event mysql_fetch_assoc($sql_result);
            if(!isset(
    $_REQUEST["people"]) or $_REQUEST["people"]==""$_REQUEST["people"] = 1;
            
    $price $Event["price"]*$_REQUEST["people"];
            
            
    $sql "SELECT * FROM ".$TABLES["Bookings"]." WHERE event_id = '".$Event["id"]."'";
            
    $sql_result mysql_query ($sql$connection) or die ('request "Could not execute SQL query" '.$sql);
            
            if(
    $Event["people"] > mysql_num_rows($sql_result)){
                
    $sql "INSERT INTO ".$TABLES["Bookings"]."
                        SET calendarId = '"
    .$_REQUEST["cid"]."',
                            event_id = '"
    .$_REQUEST["eid"]."',
                            customerName = '"
    SaveToDB($_REQUEST["customerName"])."',
                            email = '"
    SaveToDB($_REQUEST["email"])."',
                            phone = '"
    SaveToDB($_REQUEST["phone"])."',
                            notes = '"
    SaveToDB($_REQUEST["notes"])."',
                            people = '"
    SaveToDB($_REQUEST["people"])."',
                            dt = now()"
    ;
                
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql." ".mysql_error($connection));    
                
    $indx mysql_insert_id();
                
                list(
    $year,$month,$day) = explode("-",$Event["dt"]);
                
    $dt formatDateByCalendarId($day,$month,$year,$_REQUEST["cid"]);
                
    $eventTime formatEventTime($timeFormat$Event["startTime"], $Event["endTime"]);
                
                
    $mailheader    "From: ".stripslashes(utf8_decode($CalendarOptions["NotificationEmail"]))."\r\n";
                
    $mailheader   .= "Reply-To: ".stripslashes(utf8_decode($CalendarOptions["NotificationEmail"]))."\r\n";
                
    $mailheader   .= "MIME-Version: 1.0\r\n";
                
    $mailheader   .= "Content-type: text/html; charset=iso-8859-1\r\n";
                
                
    $EventDetails "Reservering: ".stripslashes(utf8_decode($Event["summary"]))."<br>".
                        
    "Omschrijving: ".stripslashes(utf8_decode($Event["description"]))."<br>".
                        
    "Datum en tijd: ".$dt." ".$eventTime;
                        
                
    $tokenPrice formatCurrencySign($CurrencySign[$CalendarOptions["currency"]],$CalendarOptions["currency"],number_format($price2'.'','));
                
    $cancelLink "<a href='".$SETTINGS["URL"]."cancel.php?id=".$indx."&e=".urlencode($_REQUEST["email"])."'>deze link...</a>";
                
                
    $search_tokens=array("<Name>","<Email>","<Phone>","<Notes>","<People>","<EventDetails>","<Price>","<CancelBooking>");
                
    $replace_tokens=array($_REQUEST["customerName"],$_REQUEST["email"],$_REQUEST["phone"],$_REQUEST["notes"],$_REQUEST["people"],$EventDetails,$tokenPrice,$cancelLink);
        
                
    $MESSAGE_BODY=$CalendarOptions["emailMessage"];
                
    $MESSAGE_BODY=nl2br(str_replace($search_tokens,$replace_tokens,$MESSAGE_BODY));
                
                if (
    $_REQUEST["email"]<>'') {
                    if (!
    mail($_REQUEST["email"], '=?UTF-8?B?'.base64_encode($EBLANG['ConfirmEmailSubject']).'?='$MESSAGE_BODY$mailheader)) $message.=" Failure sending e-mail.";
                };
                if (
    $CalendarOptions["NotificationEmail"]<>'') {
                        if (!
    mail($CalendarOptions["NotificationEmail"], '=?UTF-8?B?'.base64_encode($EBLANG['ConfirmEmailSubject']).'?='$MESSAGE_BODY$mailheader)) $message.=" Failure sending e-mail.";
                };
                
                if(
    $CalendarOptions["allowPaypal"]=="true" and $CalendarOptions["paypalAddress"]<>"" and $CalendarOptions["depositPayment"]>and $price>0){
                    
    $deposit $price * ($CalendarOptions["depositPayment"] / 100);
                    
    $_REQUEST["ac"]    = "redirectToPaypal";
                }
                else {
                    
    $_REQUEST["ac"] = "done";
                }
                
    $message $EBLANG['ReservationSaved'];            
                
            } else {
                
    $message $EBLANG['NotAvailable'];
                
    $_REQUEST["ac"] = "done";
            }
        }
        
        
    $sql "SELECT * FROM ".$TABLES["DAYS"]." WHERE calendarId='".$_REQUEST["cid"]."' AND dt='".$_REQUEST["dt"]."'";
        
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
        
    $DayData mysql_fetch_assoc($sql_result);
        
        list(
    $year,$month,$day) = explode("-",$_REQUEST["dt"]);
        
    $dt formatDateByCalendarId($day,$month,$year,$_REQUEST["cid"]);
        
    $timeFormat GetCalendarTimeFormat($_REQUEST["cid"]);
        
        
    $sql "SELECT * FROM ".$TABLES["CALENDARS"]." WHERE id=".$_REQUEST["cid"];
        
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
        
    $Calendar mysql_fetch_assoc($sql_result);
        
    $CalendarOptions unserialize($Calendar["options"]);    
        
        
    $fontFamily $Fonts[$CalendarOptions["fonts"]];
        
    $daysFontSize $FontSize[$CalendarOptions["daysFontSize"]];
        
    $daysFontStyle $Styles[$CalendarOptions["daysFontStyle"]];    
        
        
    $eventsFontSize $FontSize[$CalendarOptions["eventsFontSize"]];
        
    $eventsFontStyle $Styles[$CalendarOptions["eventsFontStyle"]];

        
    $year GetYear(1,$_REQUEST["dt"]);
        
    $month GetMonth(1,$_REQUEST["dt"]);
        
    $day GetDay(1,$_REQUEST["dt"]);
        
    $dt formatDateByCalendarId($day,$month,$year,$_REQUEST["cid"]);
        
        
    $eventTime "";
        if(
    $_REQUEST["eid"] != ""){
            
    $sql "SELECT * FROM ".$TABLES["EVENTS"]." WHERE id = '".$_REQUEST["eid"]."'";
            
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
            
    $Event mysql_fetch_assoc($sql_result);
            
    $eventTime formatEventTime($timeFormat$Event["startTime"], $Event["endTime"]);
        }
        
        
    if(
    $_REQUEST["ac"]=="redirectToPaypal"){
    ?>
    <table width="<?php echo $CalendarOptions["width"]; ?>" border="0" cellspacing="2" cellpadding="2">
        <tr>
            <td width="20%"><?php echo $EBLANG['Price']; ?>:</td>
            <td width="80%"><?php echo formatCurrencySign($CurrencySign[$CalendarOptions["currency"]],$CalendarOptions["currency"],number_format($price2'.'',')); ?></td>
        </tr>
        <tr>
            <td><?php echo $EBLANG['Deposit']; ?>:</td>
            <td><?php echo formatCurrencySign($CurrencySign[$CalendarOptions["currency"]],$CalendarOptions["currency"],number_format($deposit2'.'',')); ?></td>
        </tr>
    </table>
        <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
            <input type="hidden" name="cmd" value="_xclick">
            <input type="hidden" name="business" value="<?php echo $CalendarOptions["paypalAddress"]; ?>">
            <input type="hidden" name="item_name" value="Reservation">
            <input type="hidden" name="item_number" value="0001">
            <input type="hidden" name="amount" value="<?php echo number_format($deposit2'.'''); ?>">
            <input type="hidden" name="no_shipping" value="1">
            <input type="hidden" name="no_note" value="1">
            <input type="hidden" name="currency_code" value="<?php echo $Currencies[$CalendarOptions["currency"]]; ?>">
            <input type="hidden" name="lc" value="US">
            <input type="hidden" name="bn" value="PP-BuyNowBF">
            <input name="submit" type='submit' value='<?php echo $EBLANG['PayDeposit']; ?>' >
            <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
        </form>

    <?php
    } else {
    ?>
    <form action="load-date-events.php" method="post" name="frm" style="margin:0px; padding:0px" onsubmit="return false">
    <table width="<?php echo $CalendarOptions["width"]; ?>" border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td colspan="2" bgcolor="#<?php echo $CalendarOptions["monthBGColor"]; ?>"  style="font-family:'<?php echo $fontFamily?>'; color:#<?php echo $CalendarOptions["monthFontColor"]; ?>; font-size:<?php echo $eventsFontSize?>px; <?php echo $eventsFontStyle?>">
            <?php echo '<div style="float:left">'.$dt.' '.$eventTime.'</div>'?>
            <div style="float:right">
                <span style="cursor:pointer" onclick="document.getElementById('DateEvents<?php echo $_REQUEST["cid"]; ?>').innerHTML=''">X</span>&nbsp;&nbsp;
            </div>
            </td>
          </tr>        
    <?php 
        
    if(!isset($_REQUEST["ac"]) or $_REQUEST["ac"] == ""){

            
    $sql "SELECT * FROM ".$TABLES["EVENTS"]." WHERE calendarId='".$_REQUEST["cid"]."' AND dt='".$_REQUEST["dt"]."' ORDER BY dt,startTime,endTime";
            
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
            if (
    mysql_num_rows($sql_result)>0) {
            
                while (
    $EventData mysql_fetch_assoc($sql_result)) {

                    
    $eventTime formatEventTime($timeFormat$EventData["startTime"], $EventData["endTime"]);

        
    ?>
              <tr>
                <td width="10" align="left" bgcolor="#<?php echo $EventData["color"]; ?>">&nbsp;</td>
                <td width="100%" align="left"><span style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'> <?php echo $eventTime?></span><br />
                    <span style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px; <?php echo $eventsFontStyle?>'>
                    <?php echo stripslashes(utf8_decode($EventData["summary"])); ?><br />
                    <?php echo stripslashes(utf8_decode($EventData["description"])); ?>
                    </span>
                    <br />
              <?php
                    $today 
    strtotime(date("Y-m-d"));
                    
    $eventDateLong mktime(0,0,0,$month,$day,$year);
                  if(
    $eventDateLong>$today){
              
                      
    $sql_booking "SELECT SUM(people) FROM ".$TABLES["Bookings"]." WHERE calendarId = '" $_REQUEST["cid"] . "' AND event_id = '".$EventData["id"]."'";
                      
    $sql_result_booking mysql_query ($sql_booking$connection ) or die ('request "Could not execute SQL query" '.$sql_booking);
                      
    $booking_slots mysql_fetch_assoc($sql_result_booking);
                      
    $emptySlots $EventData["people"] - $booking_slots["SUM(people)"];
                      if(
    $emptySlots 0){
              
    ?>    
                        <input type="button" value="<?php echo $EBLANG['Book']; ?>" onclick="BookEvent(<?php echo $_REQUEST["cid"]; ?>,<?php echo $EventData["id"]; ?>,'<?php echo $_REQUEST["dt"]; ?>')" />
                   <?php } else { ?>
                           <strong style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['FullyBooked']; ?></strong>
               <?php      }
                      } else { 
    ?>
                   <strong style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['PassedEvent']; ?></strong>
                <?php ?>   
                </td>
              </tr>
              <?php 
                
    };
            } else {
        
    ?>
              <tr>
                <td colspan="2" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLAMG['noEventMsg']; ?></td>
              </tr>  
                <?php    
            
    };
        } elseif(
    $_REQUEST["ac"]=="booking_form") {


    $sql "SELECT * FROM ".$TABLES["EVENTS"]." WHERE calendarId='".$_REQUEST["cid"]."' AND id='".$_REQUEST["eid"]."'";
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
    $EventData mysql_fetch_assoc($sql_result);

    $sql_booking "SELECT SUM(people) FROM ".$TABLES["Bookings"]." WHERE calendarId = '" $_REQUEST["cid"] . "' AND event_id = '".$EventData["id"]."'";
    $sql_result_booking mysql_query ($sql_booking$connection ) or die ('request "Could not execute SQL query" '.$sql_booking);
    $booking_slots mysql_fetch_assoc($sql_result_booking);
    $emptySlots $EventData["people"] - $booking_slots["SUM(people)"];
    ?>
            <tr>
                  <td colspan="2" align="left" style="border-left:5px solid #<?php echo $EventData["color"]; ?>">
    <span style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px; <?php echo $eventsFontStyle?>'>
                    <?php echo stripslashes(utf8_decode($EventData["description"])); ?>
                    </span>              
                  </td>
        </tr>
            <tr>
                <td align="left" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['Name']; ?>:</td>
                <td align="left"><input type="text" name="customerName" maxlength="250" size="30" value="" /></td>
            </tr>
            <?php if($CalendarOptions["showAvailable"]=="true"){ ?>
            <tr>
              <td align="left" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['BookFor']; ?>:</td>
              <td align="left" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'>
                  <select name="people" id="people" style="width:40px">
                      <?php for($i=1$i<=$emptySlots$i++){ ?>
                      <option value="<?php echo $i?>"><?php echo $i?></option>
                      <?php ?>
                  </select>
              </td>
            </tr>
            <?php } else { ?>
                <input type="hidden" name="people" value="1" />
            <?php ?>
            <tr>
                <td align="left" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['Email']; ?>:</td>
                <td align="left"><input type="text" name="email" maxlength="250"  size="30" value="" /></td>
            </tr>
            <tr>
                <td align="left" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['Phone']; ?>:</td>
                <td align="left"><input type="text" name="phone" maxlength="250"  size="30" value="" /></td>
            </tr>
            <tr>
                <td align="left" valign="top" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $EBLANG['Comments']; ?>:<br /></td>
                <td align="left"><textarea name="notes" id="notes" cols="40" rows="5" style="width:90%"></textarea></td>
            </tr>
            <tr>
                <td align="left">&nbsp;</td>
                <td align="left"><input type="button" value="<?php echo $EBLANG['Book']; ?>" onclick="submitBooking(<?php echo $_REQUEST["eid"]; ?>,'<?php echo $_REQUEST["dt"]; ?>')" />
                <span style="cursor:pointer; font-family:<?php echo $fontFamily?>; font-size:<?php echo $eventsFontSize?>px; text-decoration:underline" onclick="<?php echo 'ajaxpage(\''.$SETTINGS["installFolder"].'load-date-events.php?dt='.$_REQUEST["dt"].'&cid='.$_REQUEST["cid"].'\',\'DateEvents'.$_REQUEST["cid"].'\',\'get\')'?>"><?php echo $EBLANG['Cancel']; ?></span></td>
            </tr>
    <?php    
        
    } elseif($_REQUEST["ac"]=="done") {
    ?>
            <tr>
                <td colspan="2" style='font-family:"<?php echo $fontFamily?>"; font-size:<?php echo $eventsFontSize?>px'><?php echo $message?></td>
            </tr>
    <?php        
        
    }
    ?>
    </table>
    </form>
    <?php
    }
    ?>
    The 'funny' thing is that tested this booking system on the try it page... with 'mine' admin email address en client email adress, the notification mail to all cemailclients are received in HTML.
    Installed on my domain 'only' all hotmail / msn clients receive in HTML, others as plain text. The guy who sold me this script assures me that I have the same script as he does on his try-it page.

    Hope you can help. Many thanks in advance, Marjan.

  • #2
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Well , I can see that ur script Supports Html for sure..
    PHP Code:
    $mailheader   .= "Content-type: text/html; charset=iso-8859-1\r\n"
    and if you chang html to plain then the message will be delivered as plain
    PHP Code:
    $mailheader   .= "Content-type: text/plain; charset=iso-8859-1\r\n"
    Maybe the HTML is Disabled in other Email Clients , ..

    Since u do recive html email to yahoo , msn .. then indeed the script works .. so you need to set other email clients u use to accept html or tell ur clients to do same .. Some email Clients Disable HTML for Security Reasons..

  • #3
    New to the CF scene
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by onasre View Post
    Maybe the HTML is Disabled in other Email Clients , ..

    Since u do recive html email to yahoo , msn .. then indeed the script works .. so you need to set other email clients u use to accept html
    Thank you for your reply onasre but: They do accept html. Otherwise I wouldn't receive the message from the 'Try-it' page (with my emailadresses) in HTML.

    Something else must be the problem...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •