Hey Guys,

I have an If statement in one of my php files. I want to send an email to my client anytime it IsApproved. So how do I make it send an email to the client when it is approved? Here is some of the code, the first if($response->IsApproved statement is what I need to add a function to email when this is active: How do I do this any suggestions?

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)));

?>

Here's my HTML simple mailer.php

//put this on top of your page
include('mailer.php');
$mailer = new Mailer;

//fill up the parameters with correct arguments
if($response->IsApproved()) {
$mailer->sendWelcome($user, $pass, $registration_id);
}

The Mailer Class/Object

<?php 
//send an email simple class / object
// those CAPS LOCK ARE constant in PHP using define()

class Mailer
{
   /**
    * sendWelcome - Sends a welcome message to the newly
    * registered user, also supplying the username and
    * password.
    */

   function sendWelcome($user, $pass, $registration_id){

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">\r\n";
	  
      $subject = "Welcome!";
      $body = $user.",<br><br>"
             ."Thank you for registering with myweb.com!<br>"
			 ."For security reasons, you must activate your membership within 2 days,<br>"
			 ."otherwise all your details will be automatically removed from our list.<br><br>"
             .'<a href="http://www.wwwwwwww.com/htdocs/validation.php?id='.$registration_id.'&email='.$user.'&target="_parent">Cleck here to activate your account now</a>.<br><br>'
			 ."Your personal account details are:<br>" 
			 ."Username: ".$user."<br>"
             ."Password: ".$pass."<br><br>"
			 .'Please save this message for future reference and keep it handy to <a href="http://www.wwwwwww.com/main.php" title="Update+Profile" target="_parent">update your profile</a> when needed.<br><br>' 
			 ."We hope you'll enjoy your Myweb membership. <br>"
			 ."Read on to see some of the possibilities that Myweb offers you.<br><br>" 
			 ."Welcome to the community!<br><br>" 
			 ."Kind regards,<br>" 
 		     ."Myweb Registration Service<br>";

      return mail($user, $subject,$body,$headers);
   }
}
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.