new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::REQUIRED, 'int' ), ); $form = new ezcInputForm( INPUT_GET, $definition ); $this->messageId = $form->message; $this->message = ezcMailTools::replyToMail( ezcPersistentSessionInstance::get()->load( "ezcM2fMail", $form->message ), new ezcMailAddress( "your-email@here.com" ), ezcMailTools::REPLY_ALL, "Re: ", "ezcM2fMail" ); $this->message->body = new ezcMailText( "" ); } if ( ezcInputForm::hasPostData() ) { $this->prepareForm(); $this->sendMail(); $this->template = "new_success"; } } 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 = $this->message; 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; } } ?>