Nicholas Cheek

LITTLE ROCK WEB DEVELOPER

This simply sends an email with the desired template with mandrill for tracking

<?php
require './mandrill/src/Mandrill.php';
$mandrill = new Mandrill('api key');
    
$email = $_POST['email'];
//$email = 'takenout.com';
$customername = $_POST['name'];
$confirmation = $charge->id;
$amount = $_POST['amount'];
$comments = $_POST['comments'];
$messages = "Hello " . $email . ",\n\n<br /><br />";
$messages .= "You have successfully made a payment of " . $amount . ".\n\n<br />";
$messages .= "Your confirmation number is: ".$confirmation."\n\n<br /><br />";


$messages .= '<h2>Charge Details</h2>';
if ($_POST['comments']){
$messages .= '<p>'.$comments.'</p><br />';
}
$messages .= '<p>Here are details of your charge:</p>';            
$messages .= '<table class="table">';
$messages .= '<thead>';
$messages .= '<tr>';
$messages .= '<th>Firstname</th>';
$messages .= '<th>Copay Amount</th>';
$messages .= '</tr>';
$messages .= '</thead>';
$messages .= '<tbody>';

foreach(array_combine($_POST['copay_name'], $_POST['copay_amt']) as $name => $amt){
		//$messages .= $name." : $".$amt." \n\n<br />";
		$messages .= '<tr>';
		$messages .= '<td>'.$name.'</td>';
		$messages .= '<td>'.$amt.'</td>';
		$messages .= '</tr>';
		}
$messages .= '</tbody>';
$messages .= '</table>';



$message = array(
    'subject' => 'Your payment to Finnegan Health.',
    'from_email' => 'from@',
    'html' => $messages,
    'bcc_address' => "bcc@",
    'to' => array(
    			array('email' => $email, 'name' => $email)
    			),
 
    'merge_vars' => array(array(
        'rcpt' => $email,
        'vars' =>
        array(
            array(
                'name' => 'FIRSTNAME',
                'content' => $customername),
            array(
                'name' => 'MESSAGE',
                'content' => $messages)
    ))));

$template_name = 'test';

$template_content = array(
    array(
        'name' => 'main',
        'content' => $messages)

);

$response = ($mandrill->messages->sendTemplate($template_name, $template_content, $message));			
				
				
  }
  catch (Exception $e) {
	$error = '<div class="alert alert-danger">
			  <strong>Error!</strong> '.$e->getMessage().'
			  </div>';
  }
}
?>
						

LITTLE ROCK WEB DEVELOPER

Living the dream.

nick@nicholascheek.com