0

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

?>

Edited by drewpark88: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by phpbeginners
0

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);
   }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.