class ContactController extends AppController {
	var $name = 'Contact';
	var $uses = 'Contact';
	var $components = array('Email');

	function index() {

		if (isset($this->data)) {
			if ($this->Contact->create($this->data) && $this->Contact->validates()) {

				$name = $this->data['Contact']['firstName'] . ' ' . $this->data['Contact']['lastName'];
				$from = $this->data['Contact']['email'];
				$subject = 'Contact Us';
				$msg = $this->data['Contact']['msg'];
				
				$this->Email->sendAs = 'both'; // html, text, both
				$this->Email->layout = 'contact'; // views/layouts/email/html/contact.ctp
				$this->Email->template = 'contact';

				// set view variables as normal
				$this->set('from', $name);
				$this->set('msg', $msg);

				$this->Email->to = 'athies@gmail.com';
				$this->Email->from = $from;
				$this->Email->subject = $subject;
				
				if ($this->Email->send($msg)) {
					$this->Session->setFlash(__('contactUsSent', true));
				}

			}
		}

	}

}