1 to 2 of 2
Hi everybody,
I am stuck with the AkActionMailer. I somehow miss something between gather the Form's inputfield-values and use them to send e-mails. I followed the instructions in the /lib/AkActionMailer.php. Here is what I did:
./script/generate mailer Notifier contactNotification
Then I changed /models/notifier.php to the following:
class Notifier extends AkActionMailer
{
function contactNotification($params)
{
$this->set(array(
'recipients' => 'mymail@host.com',
'from' => $params['email'],
'subject' => $params['subject'],
'contentType' => 'text/html',
'body' => array( 'Sender' => $params['email'],
'Subject' => $params['subject'],
'Message' => $params['message']),
'headers' => array( 'MIME-Version' => '1.0',
'Reply-To' => $params['email'],
'X-Mailer' => 'PHP/'.phpversion())
));
}
}
The /views/notifier/contactNotification.tpl look like this (but here I want to have all fields from the form available...):
<html>
<body>
<h1>{$Subject} by {$Sender}</h1>
{$Message}
</body>
</html>
In my Application Controller I have:
function submit()
{
if (!empty($this->params['contact']['email']))
{
if (empty($this->params['contact']['message']))
{
$this->flash['error'] = $this->t('<b>No Message</b> This is a required field.');
} else {
Ak::import_mailer('notifier');
$Notifier = new Notifier();
if ($Notifier->deliver('contactNotification', $this->params['contact']))
{
$this->flash['tip'] = $this->t('<b>Thank You!</b> We received your message.');
} else {
$this->flash['error'] = $this->t('<b>An Error occured</b> Please try again.');
}
}
} else {
$this->flash['error'] = $this->t('<b>No E-Mail</b> We need this to contact you.');
}
$this->redirectTo('index');
}
And the HTML Form in the template looks like this:
<?php $contact_form = $form_helper->form_for('contact', $Contact, array('url' => array('action' => 'submit'))); ?>
<b>_{Name}</b> <?= $contact_form->text_field('name'); ?><br />
<b>_{eMail}</b> <?= $contact_form->text_field('email'); ?><br />
<b>_{Subject}</b> <?= $form_options_helper->select('contact', 'subject', array('Contact me', 'Question', 'Information', 'General/Other')) ?><br />
<b>_{Message}</b> <?= $contact_form->text_area('message') ?><br />
<input type="submit" value="_{Send}" />
<?= $contact_form->end_form_tag(); ?>
When I send the form (with valid data), I get the message: "Fatal error: Class 'Notifier' not found in /myproject/app/controllers/myproject_controller.php"
I think I have also some basic misunderstanding in handling this. How can I access the mailer model? Forbear with me, as I am just very new to Akelos.
Anyway, appreciate all your help,
Oliver
Well, I guess you can forget it - looks like I was able to solve it thank to this Discussion :)
I edited my initial post so it shows now the working code...
However, I'd appreciate any comments on the code above if there are things I could to "better".
1 to 2 of 2