Hey Guys I have a problem with my mailing script. I have a new script to process transactions and it is working fine. What I need to do is send an email after someone submits a form ONLY if it is approved. So I have my php donation form, a process_transaction.php and a emailreceipt.php

I have an if statement that I want to send an email to my client IF the transaction is approved. All it does right now is it determines if it is approved or denied and then sends it to an approval or denied page.

How can I work in the emailreceipt.php into the following if statement:

This is a portion of process_transaction.php

if($response->IsApproved())
		{
header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}
		else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
	}
	else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));

Oh and here is emailreceipt.php maybe this will help you to see what I am trying to do.....get the fields from the donation form and send them in an email:

emailreceipt.php

<?php 


class Mailer
{
   /**
    * sendreceipt - Sends a receipt to client
    */

   function sendreceipt($to, $subject, $message, $headers){

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: "no-reply@mysite.org" <"no-reply@mysite.org">\r\n";
      
      	$to = "donation@mysite.org";
	  
      $subject = "New Donation!";

$message = '<html><body>';
$message .= '<img src="http://mysite.org/images/emailbanner.jpg" alt="Email Banner" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<head>"
$message .= "<title>Donation Information</title>"
$message .= "</head>"
$message .= "<body>"
$message .= "<p>Donation Information</p>"
$message .= "<table>"
$message .= "<tr>"
$message .= "<th>Donation Amount:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["amount"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Designation:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["Desc"]; ?></td>"
$message .= "</tr>"
$message .= "</table>"
$message .= "<p>Billing Information</p>"
$message .= "<table>"
$message .= "<tr>"
$message .= "<th>First Name:</th>"
$message .= "<th>Last Name:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["first_name"]; ?></td>"
$message .= "<td><?php echo $_GET["last_name"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Spouse Name:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["Spouse"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Address:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["address"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>City:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["city"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>State:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["state"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Zip Code:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["zip"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Country:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["country"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Phone Number:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["phone"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Email Address:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["email"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Credit Card:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $cc_number = "XXXX-XXXX-XXXX-" . substr($cc_number,-4,4); ?></td>"
$message .= "</tr>"
$message .= "</table>"
$message .= "<p>Shipping Information</p>"
$message .= "<table>"
$message .= "<tr>"
$message .= "<th>First Name:</th>"
$message .= "<th>Last Name:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_first_name"]; ?></td>"
$message .= "<td><?php echo $_GET["shipping_last_name"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Address:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_address"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>City:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_city"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>State:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_state"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Zip Code:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_zip"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Country:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["shipping_country"]; ?></td>"
$message .= "</tr>"
$message .= "</table>"
$message .= "<p>Gift of Love</p>"
$message .= "<table>"
$message .= "<tr>"
$message .= "<th>This gift is:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GiftDesc1"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Is this a pet?</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["IsThisaPet"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>If a pet what kind:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["TypeofPet"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Name:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GiftDesc2"]; ?></td>"
$message .= "</tr>
$message .= "<tr>"
$message .= "<th>Address:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GOLAddress"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>City:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GOLCity"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>State:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GOLState"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Zip:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GOLZip"]; ?></td>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<th>Country:</th>"
$message .= "</tr>"
$message .= "<tr>"
$message .= "<td><?php echo $_GET["GOLCountry"]; ?></td>"
$message .= "</tr>"
$message .= "</table>"





      return mail($to,$subject,$message,$headers);
   }
}

?>

Recommended Answers

All 4 Replies

Are you still at this? I gave you the PHP manual page for the mail function last time. I don't even seeit anywhere in your code. How do expect it to send mail without it?

Well I tried that but it is giving me an error on that line. Does this look right or what should I change?

if($response->IsApproved())
                {
           $mailer->sendreceipt($to, $subject, $message, $headers);
                }

		{
			header("Location: " . $GatewaySettings['PaymentApprovedPage']);
		}
		else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($response->GetField("ResponseReasonText")));
	}
	else
			header("Location: " . $GatewaySettings['PaymentDeniedPage'] . "?gateway_error=" . rawurlencode($transaction->GetErrorString($errorCode)));

Are you still at this? I gave you the PHP manual page for the mail function last time. I don't even seeit anywhere in your code. How do expect it to send mail without it?

you forgot to put ";" semicolon at the end of every $message .= ......;

Oh that makes sense! Thanks a bunch I appreciate the help : )

you forgot to put ";" semicolon at the end of every $message .= ......;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.