Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Tell a friend about site too.


Guest

Recommended Posts

Im using the latest version of this Contrib, but I just realised It is sending blank emails, any idea why this is? has anyone had this problem before?

 

any help/advice would be greatfully appreciated.

Link to comment
Share on other sites

Could you send me your version please? Or post the code here or something so me and other people who might come across the problem can look at it.

Link to comment
Share on other sites

Weird thing is my site started sending the emails with no problems!! So im not sure what caused the error.

 

Anyway, try this file and let me know how you get on. This file has been modded slightly to work with some contribs, but should work fine on your store.

<?php


require('includes/application_top.php');

if (!tep_session_is_registered('customer_id') && (ALLOW_GUEST_TO_TELL_A_FRIEND == 'false')) {
   $navigation -> set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
} 

$valid_product = false;
if (isset($HTTP_GET_VARS['products_id'])) {
   if ($HTTP_GET_VARS['products_id'] == 'site') {
       $valid_product = true;
   } else {
       $product_info_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
       if (tep_db_num_rows($product_info_query)) {
           $valid_product = true;
           $product_info = tep_db_fetch_array($product_info_query);
       } 
   } 
} 

if ($valid_product == false) {
   tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
} 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TELL_A_FRIEND);

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
   $error = false;

   $to_email_address = tep_db_prepare_input($HTTP_POST_VARS['to_email_address']);
   $to_name = tep_db_prepare_input($HTTP_POST_VARS['to_name']);
   $from_email_address = tep_db_prepare_input($HTTP_POST_VARS['from_email_address']);
   $from_name = tep_db_prepare_input($HTTP_POST_VARS['from_name']);
   $message = tep_db_prepare_input($HTTP_POST_VARS['message']);

   if (empty($from_name)) {
       $error = true;

       $messageStack -> add('friend', ERROR_FROM_NAME);
   } 

   if (!tep_validate_email($from_email_address)) {
       $error = true;

       $messageStack -> add('friend', ERROR_FROM_ADDRESS);
   } 

   if (empty($to_name)) {
       $error = true;

       $messageStack -> add('friend', ERROR_TO_NAME);
   } 

   if (!tep_validate_email($to_email_address)) {
       $error = true;

       $messageStack -> add('friend', ERROR_TO_ADDRESS);
   } 

   if ($error == false) {
       // ADDED THIS ALT SUBJECT FOR NON PRODUCT RECOMMENDATION
       if ($HTTP_GET_VARS['products_id'] == 'site') {
           $myEmailSubject = 'Your friend %s would like you to visit %s';
           $email_subject = sprintf($myEmailSubject, $from_name, STORE_NAME);
           $myEmailIntro = 'Hello %s,' . "\n\n" . 'Your friend %s found a great site called %s and thought you\'d like to check it out!';
           $email_body = sprintf($myEmailIntro, $to_name, $from_name, STORE_NAME) . "\n\n";
           if (tep_not_null($message)) {
               $email_body .= $message . "\n\n";
           } 
           $email_body .= 'Check out the site below.' . "\n\n" . HTTP_SERVER . "\n\n" .
           sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
       } else {
           $email_subject = sprintf(TEXT_EMAIL_SUBJECT, $from_name, STORE_NAME);
           $email_body = sprintf(TEXT_EMAIL_INTRO, $to_name, $from_name, $product_info['products_name'], STORE_NAME) . "\n\n";
           if (tep_not_null($message)) {
               $email_body .= $message . "\n\n";
           } 
           $email_body .= sprintf(TEXT_EMAIL_LINK, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])) . "\n\n" .
           sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "\n" . HTTP_SERVER . DIR_WS_CATALOG . "\n");
       } 
   } //END CHANGE IN LINK
   tep_mail($to_name, $to_email_address, $email_subject, $email_body, $from_name, $from_email_address); 
   // UNCOMMENT NEXT LINE ONLY IF YOU WANT THE ADDED FEATURE OF HAVING THE MAIL SENT TO YOU! CHANGE THE [email protected]
   tep_mail($to_name, '[email protected]', 'Tell A Friend Notify', $email_body, $from_name, $from_email_address);
 
$messageStack->add_session('header', sprintf(TEXT_EMAIL_SUCCESSFUL_SENT, $tellAboutWhat, tep_output_string_protected($to_name)), 'success');
   // Replaced above $HTTP_POST_VARS['products_name'] with $tellAboutWhat
   // If prduct id is in the url then redirect back to product, otherwise redirect to home page
   if ($HTTP_GET_VARS['products_id'] == 'site') {
       tep_redirect(tep_href_link(FILENAME_DEFAULT));
   } else {
       tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
   } 
} elseif (tep_session_is_registered('customer_id')) {
   $account_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
   $account = tep_db_fetch_array($account_query);

   $from_name = $account['customers_firstname'] . ' ' . $account['customers_lastname'];
   $from_email_address = $account['customers_email_address'];
} 

$breadcrumb -> add(NAVBAR_TITLE, tep_href_link(FILENAME_TELL_A_FRIEND, 'products_id=' . $HTTP_GET_VARS['products_id']));

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS;

?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;

?>">
<?php
// BOF: WebMakers.com Changed: Header Tag Controller v1.0
// Replaced by header_tags.php
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
 require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?> 
 <title><?php echo TITLE ?></title>
<?php
}
// EOF: WebMakers.com Changed: Header Tag Controller v1.0
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG;

?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php');

?>
<!-- header_eof //-->

<!-- body //-->
<table background="images/mainbg.jpg" border="0" width="766" align="center" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH;

?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH;

?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php');

?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_TELL_A_FRIEND, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']));

?><table width="465" border="0" cellpadding="0" cellspacing="0" background="images/info_back.gif">
 <tr>
   <td><img src="images/tell_top.gif" width="465" height="35"></td>
 </tr>
 <tr>
   <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php 
// NOTE THIS VAR USED SEVERAL TIMES BELOW
if ($HTTP_GET_VARS['products_id'] == 'site') {
   $tellAboutWhat = STORE_NAME;
} else {
   $tellAboutWhat = $product_info['products_name'];
} 
echo sprintf(HEADING_TITLE, $tellAboutWhat);

?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', sprintf(HEADING_TITLE, $tellAboutWhat), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT);

?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');

?></td>
     </tr>
<?php
if ($messageStack -> size('friend') > 0) {

   ?>
     <tr>
       <td><?php echo $messageStack -> output('friend');

   ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');

   ?></td>
     </tr>
<?php
} 

?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><b><?php echo FORM_TITLE_CUSTOMER_DETAILS;

?></b></td>
               <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION;

?></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><table border="0" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="main"><?php echo FORM_FIELD_CUSTOMER_NAME;

?></td>
                   <td class="main"><?php echo tep_draw_input_field('from_name');

?></td>
                 </tr>
                 <tr>
                   <td class="main"><?php echo FORM_FIELD_CUSTOMER_EMAIL;

?></td>
                   <td class="main"><?php echo tep_draw_input_field('from_email_address');

?></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');

?></td>
         </tr>
         <tr>
           <td class="main"><b><?php echo FORM_TITLE_FRIEND_DETAILS;

?></b></td>
         </tr>
         <tr>
           <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><table border="0" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="main"><?php echo FORM_FIELD_FRIEND_NAME;

?></td>
                   <td class="main"><?php echo tep_draw_input_field('to_name') . ' <span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>';

?></td>
                 </tr>
                 <tr>
                   <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL;

?></td>
                   <td class="main"><?php echo tep_draw_input_field('to_email_address') . ' <span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>';

?></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');

?></td>
         </tr>
         <tr>
           <td class="main"><b><?php echo FORM_TITLE_FRIEND_MESSAGE;

?></b></td>
         </tr>
         <tr>
           <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><?php echo tep_draw_textarea_field('message', 'soft', 40, 8);

?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');

?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1');

?></td>
               <td><?php
if ($HTTP_GET_VARS['products_id'] == 'site') {
   $pageTo = FILENAME_DEFAULT;
} else {
   $pageTo = FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id'];
} 
echo '<a href="' . tep_href_link($pageTo) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>';

?></td>
               <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE);

?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1');

?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
   </table></form></td>
 </tr>
 <tr>
   <td><img src="images/info_bottom.gif" width="465" height="12"></td>
 </tr>
</table>

</td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH;

?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH;

?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php');

?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php');

?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php');?>

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...