function sendEmail( $aForm, $sFile = 'messages.tpl', $sTargetEmail = null ){
extract( $aForm );
$oTpl =& TplParser::getInstance( );
if( !empty( $sTopic ) && !empty( $sMailContent ) && checkEmail( $sSender ) === true ){
$sMailContent = $sMailContent ;
$sTopic = "=?".$GLOBALS['config']['charset']."?B?".base64_encode( $sTopic )."?=\n";
if( !empty( $sName ) )
$sMailContent = $GLOBALS['lang']['Name_and_surname'].': '. $sName ."\n".$sMailContent;
if( !isset( $sTargetEmail ) )
$sTargetEmail = $GLOBALS['config']['email'];
if( @mail( $sTargetEmail, $sTopic, $sMailContent, 'From: '.$sSender."\r\nContent-Type: text/plain; charset=".$GLOBALS['config']['charset']."\r\n" ) ){
if( isset( $sFile ) )
return $oTpl->tbHtml( $sFile, 'MAIL_SEND_CORRECT' );
}
else{
if( isset( $sFile ) )
return $oTpl->tbHtml( $sFile, 'MAIL_SEND_ERROR' );
}
}
else{
if( isset( $sFile ) )
return $oTpl->tbHtml( $sFile, 'REQUIRED_FIELDS' );
}
}