prepareForm(); $this->sendMail(); $this->template = "new_success"; } else if ( ezcInputForm::hasGetData() ) { $definition = array( 'to' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw' ), ); $form = new ezcInputForm( INPUT_GET, $definition ); $this->to = $form->to; } } private function prepareForm() { $this->formDefinition = array( 'from' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw' ), 'to' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw' ), 'cc' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw' ), 'bcc' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw' ), 'subject' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'string' ), 'body' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'string' ), ); $this->form = new ezcInputForm( INPUT_POST, $this->formDefinition ); } private function sendMail() { $mail = new ezcM2fMail(); try { foreach ( $this->formDefinition as $field => $def ) { switch ( $field ) { case "subject": $mail->$field = $this->form->$field; break; case "body": $mail->body = new ezcMailText( $this->form->$field ); break; case "from": $mail->$field = ezcMailTools::parseEmailAddress( $this->form->$field ); break; case "bcc": case "cc": case "to": $mail->$field = ezcMailTools::parseEmailAddresses( $this->form->$field ); break; } } } catch ( ezcInputFormException $e ) { throw new Exception( "Incorrect fields: " . implode( ", ", $this->form->getInvalidProperties() ) ); } $transport = new ezcMailMtaTransport(); $transport->send( $mail ); $this->message = $mail; } } ?>