php not working

Get help with nopcart Perl, PHP or ASP checkout related issues.

Moderators: Koibito, Stefko, Randy

Re: php not working

Postby Neville » Fri Sep 04, 2009 1:48 pm

THANKS Guys.
Is there a post or can you tell me how to redirect, just in case I decide to use it?

Thanks again for all your help and a great script and cart system.
Neville
WebMaster
 
Posts: 10
Joined: Sat Aug 22, 2009 3:30 pm

Re: php not working

Postby Neville » Fri Sep 04, 2009 2:06 pm

Oh also, as I forgot to ask -
Where in the script does one place the redirect? This is not intuitive as far as I can see.
It obviously needs to replace the message at the end and as I have such a page already I can insert the Clear cart script into that.
Thanks
Neville
WebMaster
 
Posts: 10
Joined: Sat Aug 22, 2009 3:30 pm

Re: php not working

Postby Koibito » Fri Sep 04, 2009 2:47 pm

You can do a JavaScript redirect at the end:

Code: Select all
echo "<script type=\"text/javascript\">";
echo "window.location = \"http://www.company.com/thankyou.html\"";
echo "</script>";


This replaces:

Code: Select all
include($header);
echo "<h2>Thank you</h2>";
echo "Thank you for your order from our online store.  You will receive a confirmation email of your order ";
echo "momentarily.  Please contact us at $youremail if you have any questions or concerns.";
echo "<P>";
echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";
include($footer);


Don't forget to add the "delete cookie" code to the new thank you page.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: php not working

Postby Neville » Wed Sep 09, 2009 7:01 am

Guys,
Thanks again for all your help so far. I hope this last request will solve the final issue and get this working completely.
The last issue relqted to SMTP. I had the hosts upgrade the site I am working on to a new server with Pear mail.
Tests so far work MOSTLY well. The problem faced now is the sending of the CONFIRMATION email to the client.
As the $youremail = "raymonde@norickinteriors.com";
is on the host domain, that mail delivers fine.
However, because of the SMPT AUTH issue, if a NON-DOMIAN email addres is specified by the visitor, which is 100% likley, then an error response is given and then the THANK YOU redirect happens.
The error is
SMTP server response <nevb@webmail.co.za> no such user here (response abridged)
The host company says that SMTP auth must be activated to send that confo mail.
I am not a PHP writer and have NO clue how to modify the script.
Here is the script currently:

Code: Select all
<?php


$returnpage    = "http://www.norickinteriors.com/select.html";
$youremail     = "raymond@norickinteriors.com";
$csvfilename   = "";
$csvquote      = "\"\"";
$mode          = "EMAIL";


//##############################################################
//#FUNCTION:   doFormError                                     #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating a form        #
//#            submission error occurred.                      #
//##############################################################
function doFormError($errString) {

   

    echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
    echo "$errString<BR><BR>\n";
    echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE='  Return to the checkout page '><HR>";

   

    exit;
}

//##############################################################
//#FUNCTION:   doError                                         #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating an error      #
//#            occurred.                                       #
//##############################################################
function doError($errString) {

   

    echo "$errString<BR><BR>\n";

   

    exit;
}



//##############################################################
//##############################################################
//###  MAIN                                                  ###
//##############################################################
//##############################################################

foreach ($_POST as $field => $value)
{
$$field = $value;
}


if (($b_company == "") || ($b_name == "") || ($b_addr == "") || ($b_city == "") || ($b_country == "") || ($b_phone == "") || ($b_email == "")) {
  doFormError("I'm sorry, but it appears that you forgot to fill in a required field.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}

//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$b_email)) ) {
  doFormError("You submitted an invalid email address.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
 exit;
}

$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "A new enquiry has been received at Norick Interiors.  A summary of this information appears below.\n";
$strMessageBody .= "\n";
$strMessageBody .= "Enquiry Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Contact Details: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $b_company $b_name \n";
$strMessageBody .= "   $b_addr \n";
$strMessageBody .= "   $b_addr2 \n";
$strMessageBody .= "   $b_city, $b_country  $b_pcde \n";
$strMessageBody .= "   $b_phone \n";
$strMessageBody .= "   $b_fax \n";
$strMessageBody .= "   $b_email \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Delivery Address: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $s_company $s_name \n";
$strMessageBody .= "   $s_addr \n";
$strMessageBody .= "   $s_addr2 \n";
$strMessageBody .= "   $s_city $s_country  $s_pcde \n";
$strMessageBody .= "   $s_phone \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qty  Price   Product ID  - Product Description\n";
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "$QUANTITY_1    TBA    $ID_1 - $NAME_1   $ADDTLINFO_1  \n";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2    TBA   $ID_2 - $NAME_2   $ADDTLINFO_2  \n";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3    TBA   $ID_3 - $NAME_3   $ADDTLINFO_3  \n";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4    TBA    $ID_4 - $NAME_4   $ADDTLINFO_4  \n";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5    TBA    $ID_5 - $NAME_5   $ADDTLINFO_5  \n";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6    TBA    $ID_6 - $NAME_6   $ADDTLINFO_6  \n";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7    TBA    $ID_7 - $NAME_7   $ADDTLINFO_7  \n";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8    TBA    $ID_8 - $NAME_8   $ADDTLINFO_8  \n";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9   TBA    $ID_9 - $NAME_9   $ADDTLINFO_9  \n";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10    TBA    $ID_10 - $NAME_10   $ADDTLINFO_10 \n";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11    TBA    $ID_11 - $NAME_11   $ADDTLINFO_11 \n";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12    TBA    $ID_12 - $NAME_12   $ADDTLINFO_12 \n";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13    TBA    $ID_13 - $NAME_13   $ADDTLINFO_13 \n";}
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "SUBTOTAL: $SUBTOTAL \n";
$strMessageBody .= "TOTAL: $TOTAL \n";
$strMessageBody .= "\n";
$strMessageBody .= "FREIGHT: $SHIPPING \n";
$strMessageBody .= "\n\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "--------- \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";


if( $mode == "BOTH" || $mode == "EMAIL") {
   //# Send email order to you...
   $mailheaders = "From: $b_email\r\n";
   $mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
   $subject = "New Enquiry for Quote from Website";
   mail($youremail, $subject, $strMessageBody, $mailheaders);
}


if( $mode == "BOTH" || $mode == "FILE") {
   
   $csvcomments = $comment;
   if (!$CSVF = fopen($csvfilename,'a')) {
       doError("Unable to open CSV file for writing.  Your order has not been saved.");
       exit;
   }

   fputs($CSVF, $string);
   fputs($CSVF, "\"");
   fputs($CSVF, "$today");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_company");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_name");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_country");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_pcde");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_phone");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_fax");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_email");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_company");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_name");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_country");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_pcde");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_phone");
   fputs($CSVF, "\",\"");   
   fputs($CSVF, "$QUANTITY_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$PRICE_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SUBTOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$TOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SHIPPING");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$comment");
   fputs($CSVF, "\"\n");
   
   fclose($CSVF);
}

//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
$subject = "Enquiry Confirmation";
mail($b_email, $subject, $strMessageBody, $mailheaders);



echo "<script type=\"text/javascript\">";
echo "window.location = \"thanks2.html\"";
echo "</script>";



?>



The hst website Knowledge base makes mention of this

For PHP:
If you need to send mail from your own designed PHP page, you'll need to use the PEAR MAIL function. Info on this function and sample code can be found in the following article:
Sending mail with PHP using SMTP-auth
If you're using an open source PHP application, the solution may vary slightly. First, check the email settings configuration option for the product, and if it has options for sending mail via SMTP, SMTP-auth, SMTP username and SMTP password, then it probably supports it out of the box, and you just need to configure those options. A few common open source products do not support this with their base/default installation, and an add-on is required. The following KB articles provide info on enabling SMTP-auth for some common, open source, PHP based solutions:
Adding SMTP-auth support to OSCommerce
Enabling SMTP-AUTH support in phpBB

http://knowledge.3essentials.com/index. ... cle&id=403
Can you possibly help to tell me how to incorporate the SMTP auth into teh script so the confo mail can be sent without error.
Thanks a ton guys
Neville
WebMaster
 
Posts: 10
Joined: Sat Aug 22, 2009 3:30 pm

Re: php not working

Postby Stefko » Wed Sep 09, 2009 7:49 am

Add this to your checkout.pl

Code: Select all
###################################
use Net::SMTP;
use HTTP::Date;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
###################################




Below is my Authenticated SMTP snippet: (to be used as reference only)

Code: Select all
# Send email conformation to the customer.....
   if($b_email eq ""){
   $b_email = $c_email;
   }
    $message2 = "To: $b_email\n";
    $message2 .= "From: $youremail\n";
     $message2 .= "Date: " . time2str() ."\n";
    $message2 .= "Subject: $subject\n";
    $message2 .= "\n\n";
    $message2 .= "$msg_line1\n";
   if ( $msg_line2 ne "" ) {
       $message2 .= "$msg_line2\n";
   }
   if ( $msg_line3 ne "" ) {
       $message2 .= "$msg_line3\n";
   }
   if ( $msg_line4 ne "" ) {
       $message2 .= "$msg_line4\n";
   }
   if ( $msg_line5 ne "" ) {
       $message2 .= "$msg_line5\n";
   }
   if ( $msg_line6 ne "" ) {
       $message2 .= "$msg_line6\n";
   }
    $message2 .= "\n";
    $message2 .= "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
    $message2 .= "Reference Number: $OrdNum\n";
    $message2 .= " \n";
if ($useUPS ne "true"){
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Bill To: \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "   Name:      $b_first $b_last \n";
    $message2 .= "   Address:   $b_addr \n";
    $message2 .= "              $b_addr2 \n";
   if ($b_state ne ""){
    $message2 .= "              $b_city, $b_state $b_zip \n";
   }
   if ($b_state eq ""){
   # $message2 .= "              $b_city, $b_state2 $b_zip \n";
    $message2 .= "              $b_city, $b_state $b_zip \n";
   }
if ($b_country ne ""){
    $message2 .= "   Country:   $b_country \n";
   }
    $message2 .= "   Phone:     $b_phone \n";
    $message2 .= "   FAX:       $b_fax \n";
    $message2 .= "   Email:     $b_email \n";
    $message2 .= " \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Credit Card Info: \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "   Card Type: $cctype \n";
    $message2 .= "   Card #:    XXXX-XXXX-XXXX-$ccnum4 \n";
    $message2 .= "   CVN #:     $cccvn \n";
    $message2 .= "   Expires:   $ccexpmon / $ccexpyear \n";
    $message2 .= " \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Ship To: \n";
    $message2 .= "-------------------------------------- \n";

   if ( $s_addr eq "" ) {
    $message2 .= "   Use Billing Address\n";
   } else {
    $message2 .= "   Name:      $s_first $s_last \n";
    $message2 .= "   Address:   $s_addr \n";
    $message2 .= "              $s_addr2 \n";
   if ($s_state ne ""){
    $message2 .= "              $s_city, $s_state $s_zip \n";
   }
   if ($s_state eq ""){
   # $message2 .= "              $s_city, $s_state2 $s_zip \n";
    $message2 .= "              $s_city, $s_state $s_zip \n";
   }
if ($s_country ne ""){
    $message2 .= "   Country:   $s_country \n";
   }
    $message2 .= "   Phone:     $s_phone \n";
    $message2 .= "   FAX:       $s_fax \n";
    $message2 .= "   Email:     $s_email \n";
   }
    $message2 .= " \n";
   }
if ($useUPS eq "true"){
       $message2 .= "-------------------------------------- \n";
    $message2 .= "Contact Info: \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "\tName:\t$c_first $c_last \n";
    $message2 .= "\tPhone:\t$c_phone \n";
    $message2 .= "\tEmail:\t$c_email \n";
    $message2 .= " \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Billing Info: \n";
    $message2 .= "-------------------------------------- \n";
if ( $b_addr eq "" ) {
    $message2 .= "\t\tUse Shipping Address\n";
   } else {
    $message2 .= "\tName:\t$b_first $b_last \n";
    $message2 .= "\tAddress:$b_addr \n";
    $message2 .= "\t\t\t$b_addr2 \n";
    $message2 .= "\t\t\t$b_city, $b_state $b_zip \n";
    $message2 .= "\tCountry:$b_country \n";
   }
    $message2 .= " \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Credit Card Info: \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "\tCard Type:\t$cctype \n";
    $message2 .= "\tCard #:\t\tXXXX-XXXX-XXXX-$ccnum4 \n";
   # $message2 .= "\tCVN #:\t\t $cccvn \n";
    $message2 .= "\tExpires:\t$ccexpmon / $ccexpyear \n";
    $message2 .= " \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Ship To: \n";
    $message2 .= "-------------------------------------- \n";
    $message2 .= "\tName:\t$c_first $c_last \n";
    $message2 .= "\tAddress:$s_addr \n";
    $message2 .= "\t\t\t$s_addr2 \n";
   # $message2 .= "\t\t\t$s_city, $s_state2 $s_zip \n";
    $message2 .= "\t\t\t$s_city, $s_state $s_zip \n";
    $message2 .= "\tCountry:$s_country \n";
    $message2 .= " \n";
   }
    $message2 .= "-------------------------------------- \n";
    $message2 .= "Purchase Info: \n";
    $message2 .= "====================================== \n";
   $num = 0;
   for($y=1;$y<=100;$y++){
      $thename="NAME_$y";
         if(length(${$thename})>3){
         $num++;
         }
      }
   foreach($x=1; $x<=$num; $x++){
      $qnt="QUANTITY_$x";
      $prce="PRICE_$x";
      $xtnd="XTEND_$x";
      $ide="ID_$x";
      $naam="NAME_$x";
      $adlinfo="ADDTLINFO_$x";
      ${$naam}=~ s/\n//g;
    $message2 .= "Qty: ${$qnt}   \nItem No: ${$ide}   \nDescpition: ${$naam}   \nAddtl. Info: ${$adlinfo}   \nPrice: \$${$prce}      Extended Price: \$${$xtnd} \n\n";
   }
    $message2 .= "======================================\n";
    $message2 .= "\n";
    $message2 .= "  $itemtotl        $ITEMTOTAL \n";
    $message2 .= "  $dcount        $DISCOUNT \n";
    $message2 .= "  $subtotl        $SUBTOTAL \n";
    $message2 .= "  $freight          $SHIPPING        SHIPPING METHOD: $METHOD  \n";
   if ( $displayfst eq "true" ) {
    $message2 .= "  $tax_gst       $GST \n";
   }
    $message2 .= "  $tax_pst         $TAX \n";
    $message2 .= "\n";
    $message2 .= "  $totcost           $TOTAL \n";
    $message2 .= "\n\n";
    $message2 .= "Comments: \n";
    $message2 .= "--------------------------------------\n";
    $message2 .= "$comment \n";
    $message2 .= "--------------------------------------\n";
    $message2 .= " \n";

###################### SMTP or SENDMAIL ###################

   if ( $mailprogram ne "" ) {
   open (MAIL,"|$mailprogram");
   print MAIL  $message2;
   close MAIL;
} else {


#########################################################
my $ServerName = $mailservername;
my $MailDomain = $mailserverdomain;
my $ServerAccount = $mailserveremail;
my $ServerPwd = $mailserverpw;
my $MailFrom = $youremail;
my $MailTo = $b_email;
#########################################################

#print "Server variables assigned\n";

my $smtp = Net::SMTP->new($ServerName, Hello => $MailDomain,  Debug => 1);
die "Couldn't connect to server" unless $smtp;
#print "Server connection opened\n";

if ( !$smtp->auth($ServerAccount, $ServerPwd) ) {
#print "authentication failed or not needed\n";
}

if ( !$smtp->mail( $MailFrom ) ) {
#print "sender not accepted\n";
exit 1;
}

if (!$smtp->to( $MailTo ) ) {
##print "addressee not accepted\n";
exit 1;
}

#print "Server variables checked\n";

my $maildata =  $message2;
$smtp->data();
$smtp->datasend( $maildata );
$smtp->dataend();
$smtp->quit();
$smtp->quit;

#print "Finished sending email\n";

}

###################### SMTP or SENDMAIL ####################



For PHP I would recommend Expert Mailer http://www.xpertmailer.com/ , I have used it on many servers requiring SMTP
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS

Re: php not working

Postby Neville » Wed Sep 09, 2009 7:59 am

I am grateful for this, BUT, regrettably I am not smart enough to know exactly WHERE in the script thios needs to go, and what it needs to replace.

Am I right in thinking this replaces:

-------------
//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
$subject = "Enquiry Confirmation";
mail($b_email, $subject, $strMessageBody, $mailheaders);

--------
before the first echo of the response echo "<script type=\"text/javascript\">";?

If that is so, maybe I can do this.
Also I noted alot of additional stuff in it w/ credit card details etc which of course is not required or valid.
I am grateful if you can advise.
Thanks.
Neville
WebMaster
 
Posts: 10
Joined: Sat Aug 22, 2009 3:30 pm

Re: php not working

Postby Koibito » Wed Sep 09, 2009 7:46 pm

What Stefko posted is Perl code.

You need to send the e-mail using PEAR's SMTP mail functions.

http://www.cyberciti.biz/tips/howto-php ... ation.html

Maybe you ISP allows you to use non-PEAR SMTP?
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: php not working

Postby Neville » Thu Sep 10, 2009 5:50 am

John
The servers use PEAR mail. I would LIKE to incorporate the confirmation email to teh client, but because of the SMTP auth isue on their servers, mails will not be sent to any address NOt on the same domain.
So in order to get past that apparently I need an SMTP auth cosing part to compile and send that part of the mail.
The email to the client box with the order is delivered fine.
There is an error reponse at SEND, and then the thank you edirect displays. The order mail delivers to the domain, but of course the client confirmation does not. As already mentioned, I know almost nothing of PHp and just would like to know if there is a snippet we can insert (like what Stefko posted) that will send that part successfully.
Beyond that the whole process and script is working fantastically.

Many many thanks
Neville
WebMaster
 
Posts: 10
Joined: Sat Aug 22, 2009 3:30 pm

Re: php not working

Postby Koibito » Thu Sep 10, 2009 12:25 pm

If they don't allow you to relay, and if the SMTP server requires authentication, it's something like this:

Code: Select all
<?php

   require "Mail.php";

   $sender    = "webmaster@company.com";
   $recipient = "recipient@customer.com";
   $subject   = "New Order";
   $body      = "blah blah ...";

   $server   = "ssl://smtp.gmail.com";
   $username = "webmaster@company.com";
   $password = "secret";
   $port     = "465";

   $headers = array(
      "From"    => $sender,
      "To"      => $recipient,
      "Subject" => $subject
   );

   $smtp = Mail::factory("smtp",
      array(
        "host"     => $server,
        "username" => $username,
        "password" => $password,
        "auth"     => true,
        "port"     => 465
      )
   );

   $mail = $smtp->send($recipient, $headers, $body);

   if (PEAR::isError($mail)) {
      echo ($mail->getMessage());
   }

?>
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Re: php not working

Postby Stefko » Thu Sep 10, 2009 10:42 pm

Like I said at the bottom of my post:

For PHP I would recommend Expert Mailer http://www.xpertmailer.com/ , I have used it on many servers requiring SMTP


Let me repeat what I said before, for PHP, the script from Expert Mailer can be used for POP3, SMTP, MTA, MAIL. Damn ez to use!
I am converting over 60 sites from SENDMAIL to SMTP because soon SENDMAIL will no longer be supported, both PHP and PERL

As to the PERL script, your correct it's PERL , but PERL and PHP are formatted nearly the same, so us it as a reference.
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS

Previous

Return to Help: Perl/PHP/ASP Checkout

Who is online

Users browsing this forum: No registered users and 1 guest