85 $CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
86 $Settings->load_settings( $CachedMultyFS->get_config( __FILE__ ,
'cf_mail' ) );
87 $this->Timeout = $Settings->get_setting(
'timeout' , 0 );
113 $this->LastCallTime = microtime(
true ) - $this->Timeout / 1000000;
115 $this->AutoMarkup =
get_package(
'page::auto_markup' ,
'last' , __FILE__ );
116 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
117 $this->Tags =
get_package(
'string::tags' ,
'last' , __FILE__ );
119 catch( Exception $e )
151 private function get_headers( $From , $Sender )
157 $Headers [] =
"MIME-Version: 1.0\r\n";
158 $Headers [] =
"Content-type: text/plain; charset=utf-8\r\n";
160 if( $From !==
false )
162 if( $Sender !==
false )
164 $Headers [] =
'From: =?utf-8?B?'.base64_encode( $Sender ).
"?= <$From>\r\n";
168 $Headers [] =
"From: $From\r\n";
171 $Headers [] =
'X-Mailer: PHP/'.phpversion();
175 catch( Exception $e )
203 private function compile_string( $Str )
207 $Str = $this->Tags->compile_ultimix_tags( $Str );
209 $this->AutoMarkup->compile_string( $Str );
213 catch( Exception $e )
253 function send_email( $From , $To , $Subject , $Message , $Sender =
false )
257 if( microtime(
true ) < $this->LastCallTime + $this->Timeout / 1000000 )
259 usleep( $this->LastCallTime + $this->Timeout / 1000000 - microtime(
true ) );
262 $Subject = $this->compile_string( $Subject );
263 $Message = $this->compile_string( $Message );
265 $Headers = $this->get_headers( $From , $Sender );
267 if( mail( $To , $Subject , $Message , implode(
'' , $Headers ) ) ===
false )
269 throw(
new Exception(
'An error occured while sending email' ) );
272 catch( Exception $e )