mirror of
https://github.com/shadoll/sLetter.git
synced 2025-12-20 03:27:00 +00:00
auto sender detect by IP
This commit is contained in:
@@ -23,6 +23,7 @@ $letter->set([
|
|||||||
'fromMail' => "site@site.com", // sender email
|
'fromMail' => "site@site.com", // sender email
|
||||||
'fromName' => "SiteLetter", // sender name
|
'fromName' => "SiteLetter", // sender name
|
||||||
'toMail' => "info@site.com", // resipient email
|
'toMail' => "info@site.com", // resipient email
|
||||||
|
'senderDetect' => true, // detect sender location by IP, default 'true'
|
||||||
'senderIP' => $_SERVER['REMOTE_ADDR'],
|
'senderIP' => $_SERVER['REMOTE_ADDR'],
|
||||||
'mailgun_apikey' => 'key',
|
'mailgun_apikey' => 'key',
|
||||||
'mailgun_domain' => 'mg.site.com',
|
'mailgun_domain' => 'mg.site.com',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* @author sHa <sha@shadoll.com>
|
* @author sHa <sha@shadoll.com>
|
||||||
* @package sLetter
|
* @package sLetter
|
||||||
* @version 18.2.13-5
|
* @version 18.2.13-6
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ class sLetter{
|
|||||||
public $error = false;
|
public $error = false;
|
||||||
public $status = "";
|
public $status = "";
|
||||||
|
|
||||||
|
private $senderDetect = true;
|
||||||
private $sender = "mail";
|
private $sender = "mail";
|
||||||
private $header = "";
|
private $header = "";
|
||||||
private $message = "";
|
private $message = "";
|
||||||
@@ -34,6 +35,8 @@ class sLetter{
|
|||||||
|
|
||||||
function __construct(){
|
function __construct(){
|
||||||
$this->setLang(require_once(__DIR__."/lng/".$this->language.".php"));
|
$this->setLang(require_once(__DIR__."/lng/".$this->language.".php"));
|
||||||
|
if($this->senderDetect)
|
||||||
|
$this->detect();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setData($data,$return=false){
|
function setData($data,$return=false){
|
||||||
@@ -107,6 +110,9 @@ class sLetter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detect($return=false){
|
function detect($return=false){
|
||||||
|
if(empty($this->senderIP))
|
||||||
|
$this->senderIP = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
if(!empty($this->senderIP)){
|
if(!empty($this->senderIP)){
|
||||||
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$this->senderIP));
|
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$this->senderIP));
|
||||||
if($query && $query['status'] == 'success'){
|
if($query && $query['status'] == 'success'){
|
||||||
|
|||||||
Reference in New Issue
Block a user