Hello,
I am trying to send send an email in response to a form submission. The email will send until I populate the email template with the data. Does anybody know why this might be?
Here is my code...
function EnquireAction($data, $form) {
$submission = new Enquiry();
$form->saveInto($submission);
$submission->write();
Debug::show($adminbody);
$Full_name = $data['First_name']." ".$data['Surname'];
$Wine = $data['Wine_name'].", ".$data['Vintage'].", ".$data['Region'].", ".$data['Colour'];
$email = new Email(**FROM EMAIL**, **SEND TO**, "New Wine List Enquiry");
$email->setTemplate('AdminWineEnquiry');
$email->populateTemplate(
array(
'FullName' => $Full_name,
'Email' => $data['Email'],
'Telephone' => $data['Telephone'],
'Wine' => $Wine,
'Price' => $data['price'],
'Desc' => $data['Desc']
)
);
if($email->send()){
Debug::show($email);
}else{
Debug::show("Not sent");
}
//Director::redirectBack(Director::baseURL(). "/thank-you");
}
The template is...
Hi Ben,<br/><br/>
<p>You have had a new enquiry from the wine list.</p>
<p>From: $FullName</p>
<p>Email: $Email</p>
<p>Telephone: $Telephone</p>
<p>Wine: $Wine</p>";
<p>Price on website: £$Price</p>
<p>User comments: $Desc</p>
<p>Regards<br/>
The website</p>