forked from devsam/core
config 설정 방식을 함수를 이용하도록 변경
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
require_once(__dir__.'/../e_lib/util.php');
|
||||
require_once(__dir__.'/../e_lib/meekrodb.2.3.class.php.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.phpmailer.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.smtp.php');
|
||||
|
||||
function newRootDB(){
|
||||
$host = '_host_';
|
||||
$user = '_user_';
|
||||
$password = '_password_';
|
||||
$dbName = '_dbName_';
|
||||
$port = _port_;
|
||||
$encoding = 'utf8';
|
||||
|
||||
return new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||
}
|
||||
|
||||
function newMailObj(){
|
||||
$mailType = '_mailType_';
|
||||
$mailSubType = '_mailSubType_';
|
||||
$checkAuth = _mailCheckAuth_;//boolean
|
||||
$host = '_mailHost_';
|
||||
$user = '_mailUser_';
|
||||
$password = '_mailPassword_';
|
||||
$address = '_mailAddress_';
|
||||
$nickname = '_mailNickname_';
|
||||
$port = _mailPort_;//number
|
||||
$ignoreCert = _mailIgnoreCert_;//boolean
|
||||
|
||||
if($mailType == 'smtp'){
|
||||
$objMail = new PHPMailer();
|
||||
$objMail->isSMTP();
|
||||
$objMail->setFrom($address);
|
||||
$objMail->Hostname = $host;
|
||||
$objMail->FromName = $nickname;
|
||||
$objMail->Port = $port;
|
||||
|
||||
if($checkAuth){
|
||||
$objMail->SMTPAuth = true;
|
||||
$objMail->Username = $user;
|
||||
$objMail->Password = $password;
|
||||
|
||||
}
|
||||
if($ignoreCert){
|
||||
$objMail->SMTPOptions = array (
|
||||
'ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'allow_self_signed' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if($mailSubType == 'tls'){
|
||||
$objMail->SMTPSecure = 'tls';
|
||||
}
|
||||
else if($mailSubType == 'ssl'){
|
||||
$objMail->SMTPSecure = 'ssl';
|
||||
}
|
||||
|
||||
return $objMail;
|
||||
}
|
||||
else if($mailType == 'mail'){
|
||||
throw new BadMethodCallException('Not Implemented');
|
||||
}
|
||||
else if($mailType == 'google'){
|
||||
throw new BadMethodCallException('Not Implemented');
|
||||
}
|
||||
else{
|
||||
throw new InvalidArgumentException('Invalid Mail Type');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ require_once(ROOT.W.F_FUNC.W.'class._Mail.php');
|
||||
require_once(ROOT.W.F_CONFIG.W.SETTING.PHP);
|
||||
|
||||
if($SETTING->IsExist()) {
|
||||
$MAIL = new _Mail($SETTING->MailHost(), $SETTING->MailPort(), $SETTING->MailId(), $SETTING->MailPw(), $SETTING->MailAddr());
|
||||
$MAIL = new _Mail();
|
||||
} else {
|
||||
Error('설정 파일이 없습니다. 설정을 먼저 하십시요!');
|
||||
}
|
||||
|
||||
+3
-18
@@ -1,30 +1,15 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.W.E_LIB.W.'phpmailer5/class.phpmailer.php');
|
||||
require_once(ROOT.W.E_LIB.W.'phpmailer5/class.smtp.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
|
||||
class _Mail {
|
||||
private $objMail;
|
||||
|
||||
public function __construct($host, $port, $id, $pw, $addr) {
|
||||
$this->objMail = new PHPMailer();
|
||||
$this->objMail->IsSMTP();
|
||||
$this->objMail->SMTPAuth = false;
|
||||
//$this->objMail->SMTPSecure = 'ssl';//TODO 제대로된 Mailer 옵션 설정
|
||||
$this->objMail->Host = $host;
|
||||
$this->objMail->Port = $port;
|
||||
$this->objMail->Username = $id;
|
||||
$this->objMail->Password = $pw;
|
||||
public function __construct() {
|
||||
$this->objMail = newMailObj();
|
||||
$this->objMail->ContentType = 'text/plain';
|
||||
$this->objMail->CharSet = 'utf-8';
|
||||
$this->objMail->Encoding = 'base64';
|
||||
$this->objMail->SetFrom($addr);
|
||||
$this->objMail->SMTPOptions = array (
|
||||
'ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'allow_self_signed' => true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function Send($to, $subject, $content) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once(__dir__.'/../../d_setting/conf.php');
|
||||
|
||||
function newDB(){
|
||||
$host = '_host_';
|
||||
$user = '_user_';
|
||||
$password = '_password_';
|
||||
$dbName = '_dbName_';
|
||||
$port = _port_;
|
||||
$encoding = 'utf8';
|
||||
|
||||
return new MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||
}
|
||||
Reference in New Issue
Block a user