SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 20/10/2018, 06:55 PM   #141
playstores
Big Clucker
 
Join Date: Feb 2018
Posts: 111
Reputation: 3
Default Re: My Mailer Include

php script reup?
playstores is offline   Reply With Quote
Old 20/10/2018, 08:36 PM   #142
Chaprnks
Gangsta
 
Chaprnks's Avatar
 
Join Date: Sep 2007
Location: Soviet America
Posts: 565
Reputation: 69
Default Re: My Mailer Include

This include is bundled within every russian gamemode released.. ever. Now I know where it came from, interesting
__________________
Chaprnks is offline   Reply With Quote
Old 16/03/2019, 12:15 PM   #143
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 52
Reputation: 0
Default Re: My Mailer Include

Quote:
Originally Posted by Slice View Post
Hey,
I noticed there are a couple of functions for sending e-mails on the forums and none of them really work properly (no offence).
This, I believe, should be able to handle most charsets (I'm not sure about multi-byte, please let me know how it goes).
It can handle quotes, slashes, special characters, etc.
It also runs relatively fast:
Code:
Bench for SendMail: executes, by average, 32 times/ms.
That doesn't mean you should send mails 32 times in a millisecond!

Usage
PHP Code:
SendMailto[], sender_email[], sender_name[], subject[], message[] ); 
Example
Create a filterscript with the contents below and load it.
pawn Code:
#define MAILER_URL "my-server.com/mailer.php" // This has to be defined BEFORE you include mailer.

#include <mailer>

public OnFilterScriptInit( )
{
    SendMail( "your.email@here.ok", "roleplay.server@example.com", "Roleplay \"Server\"", "My \"måïlër\" & it's sübjéct!", "Hèllö höw årë yoü? I'm \"writing\" weird simply to test if my mailer script can handle it without any problems. Göt å próblëm wïth thät?" );
}

Download
Put mailer.inc in your pawno\include folder and upload mailer.php to a web server that has PHP (you may need to configure it's SMTP server).

mailer.inc
mailer.php
Look good, if u can fix links maybe I try it
OuDayas is offline   Reply With Quote
Old 14/04/2019, 01:20 PM   #144
playstores
Big Clucker
 
Join Date: Feb 2018
Posts: 111
Reputation: 3
Default Re: My Mailer Include

Yeah would be good.

Does nobody got these files?
playstores is offline   Reply With Quote
Old 15/04/2019, 01:22 PM   #145
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,836
Reputation: 1607
Default Re: My Mailer Include

mailer.php:
PHP Code:
<?php
    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' ] ),
        
$_POST'm' ],
        
implode(
            
"\r\n",
            array
            (
                
'From: "' addslashes$_POST'f' ] ) . "\" <{$_POST'n' ]}>",
                
"Reply-To: {$_POST['f']}",
                
"X-Mailer: PHP/" phpversion( ),
            )
        )
    );
?>
mailer.pwn:
Code:
#include <a_samp>
#include <a_http>

#if ( !defined MAILER_MAX_MAIL_SIZE )
	#define MAILER_MAX_MAIL_SIZE  (1024)
#endif

#if ( !defined MAILER_URL )
	#error Please define MAILER_URL before including the mailer include.
#endif

stock SendMail( const szReceiver[ ], const szSenderMail[ ], const szSenderName[ ], const szSubject[ ], const szMessage[ ] )
{
	new
		szBuffer[ MAILER_MAX_MAIL_SIZE ] = "t=",
		iPos    = strlen( szBuffer ),
		iLength = strlen( szReceiver )
	;
	
	memcpy( szBuffer, szReceiver, iPos * 4, ( iLength + 1 ) * 4 );
	
	StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
	
	strcat( szBuffer, "&f=" );
	
	iPos    = strlen( szBuffer );
	iLength = strlen( szSenderName );
	
	memcpy( szBuffer, szSenderName, iPos * 4, ( iLength + 1 ) * 4 );
	
	StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
	
	strcat( szBuffer, "&n=" );
	
	iPos    = strlen( szBuffer );
	iLength = strlen( szSenderMail );
	
	memcpy( szBuffer, szSenderMail, iPos * 4, ( iLength + 1 ) * 4 );
	
	StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
	
	strcat( szBuffer, "&s=" );
	
	iPos    = strlen( szBuffer );
	iLength = strlen( szSubject );
	
	memcpy( szBuffer, szSubject, iPos * 4, ( iLength + 1 ) * 4 );
	
	StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
	
	strcat( szBuffer, "&m=" );
	
	iPos    = strlen( szBuffer );
	iLength = strlen( szMessage );
	
	memcpy( szBuffer, szMessage, iPos * 4, ( iLength + 1 ) * 4 );
	
	StringURLEncode( szBuffer[ iPos ], 1024 - iPos );
	
	HTTP( 0xD00D, HTTP_POST, MAILER_URL, szBuffer, "OnMailScriptResponse" );
}

forward OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] );
public  OnMailScriptResponse( iIndex, iResponseCode, const szData[ ] )
{
	if ( szData[ 0 ] )
		printf( "Mailer script says: %s", szData );
}

stock StringURLEncode( szString[ ], iSize = sizeof( szString ) )
{
	for ( new i = 0, l = strlen( szString ); i < l; i++ )
	{
		switch ( szString[ i ] )
		{
			case '!', '(', ')', '\'', '*',
			     '0' .. '9',
			     'A' .. 'Z',
			     'a' .. 'z':
			{
				continue;
			}
			
			case ' ':
			{
				szString[ i ] = '+';
				
				continue;
			}
		}
		
		new
			s_szHex[ 8 ]
		;
		
		if ( i + 3 >= iSize )
		{
			szString[ i ] = EOS;
			
			break;
		}
		
		if ( l + 3 >= iSize )
			szString[ iSize - 3 ] = EOS;
		
		format( s_szHex, sizeof( s_szHex ), "%02h", szString[ i ] );
		
		szString[ i ] = '%';
		
		strins( szString, s_szHex, i + 1, iSize );
		
		l += 2;
		i += 2;
		
		if ( l > iSize - 1 )
			l = iSize - 1;
	}
}
Slice is offline   Reply With Quote
Old 15/04/2019, 02:23 PM   #146
XStormiest
Gangsta
 
Join Date: Jun 2012
Location: Continent: Europe, Country: Romania, City: Buzau
Posts: 544
Reputation: 45
Default Re: My Mailer Include

I get this while trying to use your code...
Code:
[17:20:51] Mailer script says: 
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\Programe\Xampp\htdocs\site\mailer.php on line 20
__________________
XStormiest is offline   Reply With Quote
Old 15/04/2019, 02:26 PM   #147
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,836
Reputation: 1607
Default Re: My Mailer Include

Your error explains what you have to do.
Slice is offline   Reply With Quote
Old 15/04/2019, 04:33 PM   #148
Variable™
Gangsta
 
Join Date: Jul 2015
Posts: 779
Reputation: 175
Default Re: My Mailer Include

It doesn't send anything to my email, doesn't return any errors but doesn't work as well.
__________________
MW4 Community

Variable™ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tool/Web/Other] [WEB | SCRIPT] In-Game Mailer lolumadd Filterscripts 23 28/08/2011 11:41 AM


All times are GMT. The time now is 04:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.