SA-MP Forums Archive
mailer include - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mailer include (/showthread.php?tid=627769)



mailer include - MerryDeer - 01.02.2017

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?


Re: mailer include - iLearner - 01.02.2017

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)


Re: mailer include - MerryDeer - 01.02.2017

But why my server crash due that? it mean if website is down i can't send mails?


Re: mailer include - BiosMarcel - 01.02.2017

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.


Re: mailer include - MerryDeer - 01.02.2017

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


Re: mailer include - iLearner - 01.02.2017

Use crashdetect, possibiliy with -d3 tag.


Re: mailer include - MerryDeer - 01.02.2017

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.


Re: mailer include - iLearner - 01.02.2017

Quote:
Originally Posted by iLearner
Посмотреть сообщение
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)
^^ Try sending a http request, if the website is off it will send error 404


Re: mailer include - MerryDeer - 01.02.2017

So http is already send my sendmail function, so there i could do check?


Re: mailer include - MerryDeer - 01.02.2017

Код:
<?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?