auto sender detect by IP

This commit is contained in:
sHa
2018-02-12 12:31:43 +02:00
parent 6cb972fe73
commit 002fbbb4fc
2 changed files with 8 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ $letter->set([
'fromMail' => "site@site.com", // sender email
'fromName' => "SiteLetter", // sender name
'toMail' => "info@site.com", // resipient email
'senderDetect' => true, // detect sender location by IP, default 'true'
'senderIP' => $_SERVER['REMOTE_ADDR'],
'mailgun_apikey' => 'key',
'mailgun_domain' => 'mg.site.com',

View File

@@ -3,7 +3,7 @@
*
* @author sHa <sha@shadoll.com>
* @package sLetter
* @version 18.2.13-5
* @version 18.2.13-6
*
*/
@@ -16,6 +16,7 @@ class sLetter{
public $error = false;
public $status = "";
private $senderDetect = true;
private $sender = "mail";
private $header = "";
private $message = "";
@@ -34,6 +35,8 @@ class sLetter{
function __construct(){
$this->setLang(require_once(__DIR__."/lng/".$this->language.".php"));
if($this->senderDetect)
$this->detect();
}
function setData($data,$return=false){
@@ -107,6 +110,9 @@ class sLetter{
}
function detect($return=false){
if(empty($this->senderIP))
$this->senderIP = $_SERVER['REMOTE_ADDR'];
if(!empty($this->senderIP)){
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$this->senderIP));
if($query && $query['status'] == 'success'){