Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a second recipient to this

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
Hello

I have been handed this form structure by a client who wants to add a second email address (acct@thesite.com) - The form gets the existing address from a pre-populated field called sEmail -- (admin@thesite.com) -- the contents of the email are in a text style template called _sendOrderToClient.tpl' It captures other field data like this $aCourier, $iOrder $sName $sAmount $sTax.

Can a Bcc be added, or another address --

What they want is a second copy of the form (it's a receipt) to the accounting Dept. Is there a way to do this - I tried to add it via this way

$sTo = $_POST['sEmail,acct@thesite.com'];
$sTo = $_POST['sEmail'],['acct@thesite.com'];
$sTo = $_POST['sEmail','acct@thesite.com'];

Nothing seems to work - I've looked around but I'm lost - can it be done? If so what am I missing.....?

Code:
<?php
if( $p == 'ordersDelivery' && isset( $_SESSION['iOrderSession_'.LANGUAGE] ) && is_numeric( $_SESSION['iOrderSession_'.LANGUAGE] ) ){
  
  if( !function_exists( 'throwOrdersIdTemp' ) ){
    require_once DIR_CORE.'orders-'.$config['db_type'].'.php';
    require_once DIR_CORE.'orders.php';

    require_once DIR_CORE.'couriers-'.$config['db_type'].'.php';
    require_once DIR_CORE.'couriers.php';
  }

  if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' && checkOrderFields( $_POST ) ){
    $iOrder     = $_SESSION['iOrderSession_'.LANGUAGE];

    [COLOR=blue] $sTo        = $_POST['sEmail']; [/color]
    	
    $sTemplate  = $config['language'].'[COLOR=green]_sendOrderToClient.tpl'[/color];
    $sTitle     = $tpl->tbHtml( $sTemplate, 'EMAIL_TITLE' );
    
    $sEmailContent = listBasket( $iOrder, $sTemplate );

    if( !empty( $_POST['iCourier'] ) && !empty( $sEmailContent ) ){
      $sEmailContent = $tpl->tbHtml( $sTemplate, 'EMAIL_HEAD' ).$sEmailContent;
      $aCourier = explode( '|', $_POST['iCourier'] );
      $aCourier = throwCourier( $aCourier[0] );
      if( function_exists( 'changeCourierPaymentPrice' ) )
        changeCourierPaymentPrice( $aCourier, $iOrder );
      $fSummary = tPrice( $aCourier['fPrice'] + $aList['fSummary'] );
      $sSummary = changePriceFormat( $fSummary );
      $sEmailContent .=  $tpl->tbHtml( $sTemplate, 'EMAIL_FOOT' );
    }

    @mail( $sTo, $sTitle, ereg_replace( '\|n\|', "\n", $sEmailContent ), 'FROM: '.$config['email']."\r\nContent-Type: text/plain; charset=".$config['charset']."\r\n" );
  }
}
?>
 
Code:
$sTo .= ",acct@thesite.com";

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
That didn't work - but this did - I added this to the last email string --
@mail( $to = "acct@thestore.com", $sTitle, ereg_replace( '\|n\|', "\n", $sEmailContent ), 'FROM: '.$config['email'] );
}
 
it's a really bad idea to use user input like this

Code:
$sTo        = $_POST['sEmail'];

without checking and cleansing it. at the moment your form is like an open SMTP relay. simply separating email addresses by commas will allow spammers to send email to multiple addresses at the same time.

it is curious that spookie's suggestion did not work. it is probably because there is something amiss in the $_POST['email'] variable. the normal way to add a second addressee is to comma delimit the addresses.

to avoid form spam etc always cleanse user data and consider using a proper mailer class like phpmailer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top