how to send a message in different emails using cake php 1.3. when i go to 
localhost/email/emails/add it goes error 
i got this code in my controller


<?php
class EmailsController extends AppController {

    var $name = 'Emails';

    public $uses = null;
public function index() {
$this->Email->to = 'Destination <sec...@secret.com>';
$this->Email->subject = 'Testing the Email component';
$sent = $this->Email->send('POTANG INA KA!');
if (!$sent) {
echo 'ERROR: ' . $this->Email->smtpError . '<br />';
} else {
echo 'Email sent!';
}
$this->set(array(
        'name' => '',
        'url' => Router::url('/', true)
));
$this->_stop();
}

public $components = array(
        'Email' => array(
        'delivery' => 'smtp',
        'smtpOptions' => array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'username' => 'sec...@secret.com',
        'password' => 'secret'
)
)
);

}



    function view($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid email', true));
            $this->redirect(array('action' => 'index'));
        }
        $this->set('email', $this->Email->read(null, $id));
    }

    function add() {
        if (!empty($this->data)) {
            $this->Email->create();
            if ($this->Email->save($this->data)) {
                $this->Session->setFlash(__('The email has been saved', 
true));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The email could not be saved. 
Please, try again.', true));
            }
        }
    }

    function edit($id = null) {
        if (!$id && empty($this->data)) {
            $this->Session->setFlash(__('Invalid email', true));
            $this->redirect(array('action' => 'index'));
        }
        if (!empty($this->data)) {
            if ($this->Email->save($this->data)) {
                $this->Session->setFlash(__('The email has been saved', 
true));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The email could not be saved. 
Please, try again.', true));
            }
        }
        if (empty($this->data)) {
            $this->data = $this->Email->read(null, $id);
        }
    }

    function delete($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid id for email', true));
            $this->redirect(array('action'=>'index'));
        }
        if ($this->Email->delete($id)) {
            $this->Session->setFlash(__('Email deleted', true));
            $this->redirect(array('action'=>'index'));
        }
        $this->Session->setFlash(__('Email was not deleted', true));
        $this->redirect(array('action' => 'index'));
    }



in my model

<?php
class Email extends AppModel {
    var $name = 'Email';
    var $displayField = 'id';
    var $validate = array(
        'to' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 
'update' operations
            ),
        ),
        'subject' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 
'update' operations
            ),
        ),
    );
}
?>










in my view/add



<div class="emails form">
<?php echo $this->Form->create('Email');?>
    <fieldset>
        <legend><?php __('Add Email'); ?></legend>
    <?php
        echo $this->Form->input('to');
        echo $this->Form->input('subject');
    ?>
    </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
    <h3><?php __('Actions'); ?></h3>
    <ul>

        <li><?php echo $this->Html->link(__('List Emails', true), 
array('action' => 'index'));?></li>
    </ul>
</div>



in my view/index


<div class="emails index">
    <h2><?php __('Emails');?></h2>
    <table cellpadding="0" cellspacing="0">
    <tr>
            <th><?php echo $this->Paginator->sort('id');?></th>
            <th><?php echo $this->Paginator->sort('to');?></th>
            <th><?php echo $this->Paginator->sort('subject');?></th>
            <th class="actions"><?php __('Actions');?></th>
    </tr>
    <?php
    $i = 0;
    foreach ($emails as $email):
        $class = null;
        if ($i++ % 2 == 0) {
            $class = ' class="altrow"';
        }
    ?>
    <tr<?php echo $class;?>>
        <td><?php echo $email['Email']['id']; ?>&nbsp;</td>
        <td><?php echo $email['Email']['to']; ?>&nbsp;</td>
        <td><?php echo $email['Email']['subject']; ?>&nbsp;</td>
        <td class="actions">
            <?php echo $this->Html->link(__('View', true), array('action' 
=> 'view', $email['Email']['id'])); ?>
            <?php echo $this->Html->link(__('Edit', true), array('action' 
=> 'edit', $email['Email']['id'])); ?>
            <?php echo $this->Html->link(__('Delete', true), array('action' 
=> 'delete', $email['Email']['id']), null, sprintf(__('Are you sure you 
want to delete # %s?', true), $email['Email']['id'])); ?>
        </td>
    </tr>
<?php endforeach; ?>
    </table>
    <p>
    <?php
    echo $this->Paginator->counter(array(
    'format' => __('Page %page% of %pages%, showing %current% records out 
of %count% total, starting on record %start%, ending on %end%', true)
    ));
    ?>    </p>

    <div class="paging">
        <?php echo $this->Paginator->prev('<< ' . __('previous', true), 
array(), null, array('class'=>'disabled'));?>
     |     <?php echo $this->Paginator->numbers();?>
 |
        <?php echo $this->Paginator->next(__('next', true) . ' >>', 
array(), null, array('class' => 'disabled'));?>
    </div>
</div>
<div class="actions">
    <h3><?php __('Actions'); ?></h3>
    <ul>
        <li><?php echo $this->Html->link(__('New Email', true), 
array('action' => 'add')); ?></li>
    </ul>
</div>








please help me








?>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to