Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		Hi,
I use mailer include and my website was ddossing or not working i don't know, when i use sendmail function to send to email, my server crashed, it's bad because if website is down, server can instantly crash if somebody use sendmail function, it's possible to check if website is working, to prevent that crashes?
	
	
	
	
		
	
 
 
	
	
		I am not really good at those things, but you could try to send a http request with method get, it returns various values,  check if the return wasn't 404 (return code should be something else)
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		But why my server crash due that? it mean if website is down i can't send mails?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,219
	Threads: 51
	Joined: Jul 2012
	
	
 
	
	
		You didn't give much info ... your samp server calls a .php file that sends a mail? What even crashes, samp server or the machine?
Did you even test the mailing class? And why does it crash, did u check logs? Please dude, we srsly need more info.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		https://sampforum.blast.hk/showthread.php?tid=197755
In server log i get:
forward OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] );
public  OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] )
{
	if ( szData[ 0 ] )
		printf( "Mailer script says: %s", szData );
}
Mailer script says: .....
.....
A lot of stuff writing, that unable to connect to website or somethinf similar, no crash info
	
 
	
	
	
		
	
 
 
	
	
		Use crashdetect, possibiliy with -d3 tag.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		I'am sure it's that website if it's off mail can't retrieve mail services and can't send server crash. So i need to check if website is down or not, to prevent that thing.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		So http is already send my sendmail function, so there i could do check?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 723
	Threads: 366
	Joined: Jun 2016
	
	
 
	
	
		
Код:
<?php
	$header_check = get_headers("xxxx");
	$response_code = $header_check[0];
    $domain = 'xxx';
if(gethostbyname($domain) != $domain && $response_code == 'HTTP/1.1 200 OK'  )
{
    ini_set( 'html_errors', false );
   
    if ( empty( $_POST[ 't' ] ) || empty( $_POST[ 'f' ] ) || empty( $_POST[ 'n' ] ) || empty( $_POST[ 's' ] ) || empty( $_POST[ 'm' ] ) )
        die( 'Error: Missing parameters.' );
   
    mail(
        $_POST[ 't' ],
        utf8_encode( $_POST[ 's' ] ),
        "<html><body>".$_POST[ 'm' ]."</body></html>",
        implode(
            "\r\n",
            array
            (
                'MIME-Version: 1.0',
                'Content-type: text/html; charset=iso-8859-1',
                'From: "' . addslashes( $_POST[ 'f' ] ) . "\" <{$_POST[ 'n' ]}>",
                "Reply-To: {$_POST['f']}",
                "X-Mailer: PHP/" . phpversion( ),
            )
        )
    );
    }
 
?>
 It's okey?