0

Thought this code would work, it is not sending me an email upon approval. What can the problem be, I tried making changes suggested but it did not work:

if($response->IsApproved())
		{
	        $to = 'donation@valleyanimal.org';  
            	$subject = 'New Donation';
				$headers .= "MIME-Version: 1.0\r\n";
			    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
            	$headers = 'From: no-reply@valleyanimal.org';
                $message = '<html><body>';
                $message .= '<img src="http://valleyanimal.org/images/emailbanner.jpg" alt="VAC Email Banner" />';
                $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
                $message .= "<head>";
                $message .= "<title>Donation Information</title>";
                $message .= "</head>";
                $message .= "<body>";
                $message .= "<tr style='background: #eee;'><strong><p>Donation Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th><p>Donation Amount:</p></th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['amount']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Designation:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Desc']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Billing Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['first_name']}</td>";
                $message .= "<td>{$_GET['last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Spouse Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['Spouse']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['country']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Phone Number:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['phone']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Email Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['email']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Credit Card:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>XXXX-XXXX-XXXX-".substr($_GET['cc_number'] , -4, 4)."</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Shipping Information</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>First Name:</th>";
                $message .= "<th>Last Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_first_name']}</td>";
                $message .= "<td>{$_GET['shipping_last_name']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_address']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_city']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_state']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip Code:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_zip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['shipping_country']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "<tr style='background: #eee;'><strong><p>Gift of Love</strong></p></tr>";
                $message .= "<table>";
                $message .= "<tr>";
                $message .= "<th>This gift is:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc1']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Is this a pet?</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['IsThisaPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>If a pet what kind:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['TypeofPet']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Name:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GiftDesc2']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Address:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLAddress']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>City:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCity']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>State:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLState']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Zip:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLZip']}</td>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<th>Country:</th>";
                $message .= "</tr>";
                $message .= "<tr>";
                $message .= "<td>{$_GET['GOLCountry']}</td>";
                $message .= "</tr>";
                $message .= "</table>";
                $message .= "</body></html>";

            	if (mail($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)));
}
?>
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by drewpark88
0

Why did you start a duplicate thread? Mark one or the other as solved. I would just start at the beginning and go from there. First of all, start with line 1, you could do something like this:

if($response->IsApproved()) {
echo "Approved";
}

This at least tells you that it is not failing there. Is the redirect happening at all? If not that tells you the script is failing somewhere. If it is redirecting it probably stems from the message format. Try a text email and see if that is delivered, then you can modify the script accordingly. Also, line 11 is incorrect.

$message .= '<table rules="all" style="border-color: #666;"

It should be:

$message .= '<table rules="all" style="border-color: #666">';

EDIT: Nevermind, I can see that you marked it as solved.

Edited by Tekkno: n/a

0

I just noticed some other issues with your html. This would not keep the message from sending, but it would effect the appearance. Your <head> tags are in the wrong place and you have multiple <body> tags.

0

It redirects fine, but no email is sent out....

Why did you start a duplicate thread? Mark one or the other as solved. I would just start at the beginning and go from there. First of all, start with line 1, you could do something like this:

if($response->IsApproved()) {
echo "Approved";
}

This at least tells you that it is not failing there. Is the redirect happening at all? If not that tells you the script is failing somewhere. If it is redirecting it probably stems from the message format. Try a text email and see if that is delivered, then you can modify the script accordingly. Also, line 11 is incorrect.

$message .= '<table rules="all" style="border-color: #666;"

It should be:

$message .= '<table rules="all" style="border-color: #666">';

EDIT: Nevermind, I can see that you marked it as solved.

This topic has been dead for over six months. 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.