Include sendemail
#1

Hi, I want to use include sendmail and I would need a host. How can I use my web and what I need?

Actual host: geradoresjfs.host22.com/SendEmail.php
Reply
#2

This can be useful for a simple post request: https://sampwiki.blast.hk/wiki/HTTP
For the endpoint you can simply use this: http://php.net/manual/en/function.mail.php
Reply
#3

Quote:
Originally Posted by bgedition
Посмотреть сообщение
This can be useful for a simple post request: https://sampwiki.blast.hk/wiki/HTTP
For the endpoint you can simply use this: http://php.net/manual/en/function.mail.php
And how can I send emails to different emails?

EDIT: Or the question is how to extract from the database the email of player.
Reply
#4

You probably will have the player's email stored(probably when they log in) in an enum in the script.
Then you would make a POST request to an endpoint to the PHP script, in that request you would also pass the player's email, the message and the subject.

Edit:
You can use this as an example: https://sampforum.blast.hk/showthread.php?tid=351065
Reply
#5

Quote:
Originally Posted by bgedition
Посмотреть сообщение
You probably will have the player's email stored(probably when they log in) in an enum in the script.
Then you would make a POST request to an endpoint to the PHP script, in that request you would also pass the player's email, the message and the subject.

Edit:
You can use this as an example: https://sampforum.blast.hk/showthread.php?tid=351065
The email is not delivered... further down the source code:

sendemail.inc
Код HTML:
#include <a_http>

#if !defined Function
	#define Function::%0(%1)    %0(%1); public %0(%1)
#endif
Function::SendMail(EmailTo[],Subject[],Message[],EmailFrom[]) {
    new Link[1200];
    //format(Link,sizeof(Link),"saveg.ro/sendemail.php?EmailTo=%s&Subject=%s&From=%s&Message=%s",EmailTo,Subject,EmailFrom,Message);
    format(Link,sizeof(Link),"saveg.ro/sendemail.php?code=44514&EmailTo=%s&Subject=%s&Message=%s&EmailFrom=%s",EmailTo,Subject,Message,EmailFrom);
    for(new c; c < strlen(Link)+1; c++) if(Link[c] == ' ') Link[c] = '+';
    HTTP(0, HTTP_POST, Link, "", "");
    return 1;
}
sendemail.php
PHP код:
<?php 
if (isset($_GET['code'])) { //checks if request from SA:MP server contains code 
    
$code $_GET['code'];//Redefine just to look better :) 
    
if($code == 44514) { // Compare code from SA:MP request, a.k.a password to avoid spam or unauthorized requests 
        
if (isset($_GET['Message']) && !empty($_GET['Message'])) { //Checks if request from SA:MP server contains messag you want to send 
            //EmailTo[],Subject[],Message[],EmailFrom[]
            
$emailto $_GET['EmailTo'];
            
$subject $_GET['Subject'];
            
$message $_GET['Message'];//Redefine just to look better :) 
            
$message str_replace("-"," ",$message);//Replace all - back to blank space as url cant contains blank spaces
            
mail($emailto$subject$message,"From: \"SA:MP server\" <support@saveg.ro>\r\n" ."X-Mailer: PHP/" phpversion());//Send an email, format: To,Subject,Message,From 
            
echo "Email delivered";//Response message to SA:MP server, so server knows request was valid 
        

    } 

?>
EDIT: In gamemode i have:
Код HTML:
format(emails, sizeof(emails), "Salutare %s,\nAi primit acest email pentru ca pe serverul rpg.og-times.ro cineva s-a logat dintr-o locatie diferita/de pe un PC diferit pe contul tau.\nDaca tu esti persoana ce s-a logat pe cont, click pe link-ul de mai jos pentru deblocarea contului: key - %s", PlayerInfo[playerid][pNormalName], key2);
SendMail(PlayerInfo[playerid][pEmail], emails, "saveG.ro - Securitate cont / Account security", "support@saveg.ro");
Reply
#6

You can easily use custom plugin for this work, it would be good for server performance

You can also create your own listener so that you can inform players in the game player for the arrival of new email
Reply
#7

I modified:
Код HTML:
HTTP(0, HTTP_POST, Link, "", "");
In this(i gave up on includes and I inserted the function in the gamemode):
Код HTML:
HTTP(playerid, HTTP_GET, Link, "", "EmailDelivered");
Because in sendemail.php i use function $_GET. Now I get error 302 HTTP, how can I solve it?
The php script runs I tested it but only in game I get the error.

Function SendEmail:
Код HTML:
function SendMail(playerid, EmailTo[], Message[]) {
    new Link[500];
    format(Link, sizeof(Link), "mydomain.ro/sendemail.php?code=44514&EmailTo=%s&Message=%s", EmailTo, Message);
    HTTP(playerid, HTTP_GET, Link, "", "EmailDelivered");
    return 1;
}
EDIT: I replaced my web name with mydomain, mydomain.ro is just an example.
Reply
#8

I have SSL certificate(https) how can I solve this problem?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)