Hi Guys,
I've been trying to send an e-mail out and followed the official guide however I am not receiving any e-mails. I cannot figure out what is wrong, here is my code:
<?php
class ContactPage extends Page {
}
class ContactPage_Controller extends Page_Controller {
private static $allowed_actions = array('$Form');
public function Form() {
$fields = new FieldList(
new TextField('Name'),
new EmailField('Email'),
new TextareaField('Message')
);
$actions = new FieldList(
new FormAction('submit', 'Submit')
);
$validator = new RequiredFields('Name', 'Message');
return new Form($this, '$Form', $fields, $actions, $validator);
}
public function submit($data, $form) {
$email = new Email();
$email->setTo('myemail@mymail.com');
$email->setFrom($data['Email']);
$email->setSubject("Contact Message from {$data["Name"]}");
$messageBody = "
<p><strong>Name:</strong> {$data['Name']}</p>
<p><strong>Message:</strong> {$data['Message']}</p>
";
$email->setBody($messageBody);
$email->send();
return array(
'Content' => '<p>Thank you for your feedback.</p>',
'Form' => ''
);
}
}
My ContactForm.ss looks like this
$Form
my Page.ss looks like this
$Content
$Form
Note: I changed the e-mail displayed in the code above, but in my actual code I use my real e-mail.