24.03.2019, 12:55
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
Actual host: geradoresjfs.host22.com/SendEmail.php
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 |
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 |
#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;
}
<?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
}
}
}
?>
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");
HTTP(0, HTTP_POST, Link, "", "");
HTTP(playerid, HTTP_GET, Link, "", "EmailDelivered");
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; }