mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
Implement test SMS sending
This commit is contained in:
parent
85c9b633ec
commit
b44175aba2
5 changed files with 104 additions and 13 deletions
|
|
@ -211,7 +211,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a test email using a temporary configuration.
|
* Send a test mail.
|
||||||
*/
|
*/
|
||||||
public function procAdvanced_MailerAdminTestSendMail()
|
public function procAdvanced_MailerAdminTestSendMail()
|
||||||
{
|
{
|
||||||
|
|
@ -250,23 +250,23 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
if (count($oMail->errors))
|
if (count($oMail->getErrors()))
|
||||||
{
|
{
|
||||||
if (config('mail.type') === 'smtp')
|
if (config('mail.type') === 'smtp')
|
||||||
{
|
{
|
||||||
if (strpos(config('mail.smtp.smtp_host'), 'gmail.com') !== false && strpos(implode("\n", $oMail->errors), 'code "535"') !== false)
|
if (strpos(config('mail.smtp.smtp_host'), 'gmail.com') !== false && strpos(implode("\n", $oMail->getErrors()), 'code "535"') !== false)
|
||||||
{
|
{
|
||||||
$this->add('test_result', Context::getLang('msg_advanced_mailer_google_account_security'));
|
$this->add('test_result', Context::getLang('msg_advanced_mailer_google_account_security'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strpos(config('mail.smtp.smtp_host'), 'naver.com') !== false && strpos(implode("\n", $oMail->errors), 'Failed to authenticate') !== false)
|
if (strpos(config('mail.smtp.smtp_host'), 'naver.com') !== false && strpos(implode("\n", $oMail->getErrors()), 'Failed to authenticate') !== false)
|
||||||
{
|
{
|
||||||
$this->add('test_result', Context::getLang('msg_advanced_mailer_naver_smtp_disabled'));
|
$this->add('test_result', Context::getLang('msg_advanced_mailer_naver_smtp_disabled'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->errors))));
|
$this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->getErrors()))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -285,4 +285,56 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
||||||
$this->add('test_result', Context::getLang('msg_advanced_mailer_test_success'));
|
$this->add('test_result', Context::getLang('msg_advanced_mailer_test_success'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a test SMS.
|
||||||
|
*/
|
||||||
|
public function procAdvanced_MailerAdminTestSendSMS()
|
||||||
|
{
|
||||||
|
$advanced_mailer_config = $this->getConfig();
|
||||||
|
$recipient_number = Context::get('recipient_number');
|
||||||
|
$country_code = intval(Context::get('country_code'));
|
||||||
|
$content = trim(Context::get('content'));
|
||||||
|
|
||||||
|
if (!$recipient_number)
|
||||||
|
{
|
||||||
|
$this->add('test_result', 'Error: ' . Context::getLang('msg_advanced_mailer_recipient_number_is_empty'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$content)
|
||||||
|
{
|
||||||
|
$this->add('test_result', 'Error: ' . Context::getLang('msg_advanced_mailer_content_is_empty'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$oSMS = new Rhymix\Framework\SMS();
|
||||||
|
$oSMS->addTo($recipient_number, $country_code);
|
||||||
|
$oSMS->setBody($content);
|
||||||
|
$result = $oSMS->send();
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
if (count($oSMS->getErrors()))
|
||||||
|
{
|
||||||
|
$this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oSMS->getErrors()))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->add('test_result', Context::getLang('msg_advanced_mailer_unknown_error'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$this->add('test_result', nl2br(htmlspecialchars($e->getMessage())));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->add('test_result', Context::getLang('msg_advanced_mailer_test_success_sms'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,3 +119,10 @@ $lang->cmd_advanced_mailer_clear_log_condition_all = 'Everything';
|
||||||
$lang->cmd_advanced_mailer_clear_log_condition = 'Over %d days';
|
$lang->cmd_advanced_mailer_clear_log_condition = 'Over %d days';
|
||||||
$lang->cmd_advanced_mailer_clear_log_button = 'Clear old logs';
|
$lang->cmd_advanced_mailer_clear_log_button = 'Clear old logs';
|
||||||
$lang->cmd_advanced_mailer_sms_test = 'SMS Test';
|
$lang->cmd_advanced_mailer_sms_test = 'SMS Test';
|
||||||
|
$lang->cmd_advanced_mailer_recipient_number = 'Recipient\'s number';
|
||||||
|
$lang->cmd_advanced_mailer_country_code = 'Country code';
|
||||||
|
$lang->cmd_advanced_mailer_country_code_help = 'Please leave the country code empty if you are sending to a domestic number.';
|
||||||
|
$lang->cmd_advanced_mailer_test_content = 'This is an SMS test from Rhymix.';
|
||||||
|
$lang->msg_advanced_mailer_recipient_number_is_empty = 'Please enter a phone number for the recipient.';
|
||||||
|
$lang->msg_advanced_mailer_content_is_empty = 'Please enter the content for your test SMS.';
|
||||||
|
$lang->msg_advanced_mailer_test_success_sms = 'The test was successful. Please check your SMS.';
|
||||||
|
|
@ -119,3 +119,10 @@ $lang->cmd_advanced_mailer_clear_log_condition_all = '모두';
|
||||||
$lang->cmd_advanced_mailer_clear_log_condition = '%d일 이상';
|
$lang->cmd_advanced_mailer_clear_log_condition = '%d일 이상';
|
||||||
$lang->cmd_advanced_mailer_clear_log_button = '오래된 기록 삭제';
|
$lang->cmd_advanced_mailer_clear_log_button = '오래된 기록 삭제';
|
||||||
$lang->cmd_advanced_mailer_sms_test = 'SMS 테스트';
|
$lang->cmd_advanced_mailer_sms_test = 'SMS 테스트';
|
||||||
|
$lang->cmd_advanced_mailer_recipient_number = '받는이 전화번호';
|
||||||
|
$lang->cmd_advanced_mailer_country_code = '국가코드';
|
||||||
|
$lang->cmd_advanced_mailer_country_code_help = '국내 번호로 발송하실 경우 국가코드는 비워 두시기 바랍니다.';
|
||||||
|
$lang->cmd_advanced_mailer_test_content = '라이믹스 SMS 발송 테스트입니다.';
|
||||||
|
$lang->msg_advanced_mailer_recipient_number_is_empty = '받는이 전화번호를 입력해 주십시오.';
|
||||||
|
$lang->msg_advanced_mailer_content_is_empty = 'SMS 내용을 입력해 주십시오.';
|
||||||
|
$lang->msg_advanced_mailer_test_success_sms = '테스트에 성공하였습니다. SMS를 확인해 보시기 바랍니다.';
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
$(this).attr("disabled", "disabled");
|
$(this).attr("disabled", "disabled");
|
||||||
var ajax_data = {
|
var ajax_data = {
|
||||||
recipient_name: $("#advanced_mailer_recipient_name").val(),
|
recipient_name: $("#advanced_mailer_recipient_name").val(),
|
||||||
recipient_email: $("#advanced_mailer_recipient_email").val(),
|
recipient_email: $("#advanced_mailer_recipient_email").val()
|
||||||
};
|
};
|
||||||
$.exec_json(
|
$.exec_json(
|
||||||
"advanced_mailer.procAdvanced_mailerAdminTestSendMail", ajax_data,
|
"advanced_mailer.procAdvanced_mailerAdminTestSendMail", ajax_data,
|
||||||
|
|
@ -24,6 +24,28 @@
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#advanced_mailer_test_send_sms").click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
$("#advanced_mailer_test_result").text("");
|
||||||
|
$(this).attr("disabled", "disabled");
|
||||||
|
var ajax_data = {
|
||||||
|
recipient_number: $("#advanced_mailer_recipient_number").val(),
|
||||||
|
country_code: $("#advanced_mailer_country_code").val(),
|
||||||
|
content: $("#advanced_mailer_content").val()
|
||||||
|
};
|
||||||
|
$.exec_json(
|
||||||
|
"advanced_mailer.procAdvanced_mailerAdminTestSendSMS", ajax_data,
|
||||||
|
function(response) {
|
||||||
|
$("#advanced_mailer_test_result").html(response.test_result);
|
||||||
|
$("#advanced_mailer_test_send").removeAttr("disabled");
|
||||||
|
},
|
||||||
|
function(response) {
|
||||||
|
$("#advanced_mailer_test_result").text("AJAX Error");
|
||||||
|
$("#advanced_mailer_test_send").removeAttr("disabled");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} (jQuery));
|
} (jQuery));
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<form class="x_form-horizontal" action="./" method="post" id="advanced_mailer">
|
<form class="x_form-horizontal" action="./" method="post" id="advanced_mailer">
|
||||||
<input type="hidden" name="module" value="advanced_mailer" />
|
<input type="hidden" name="module" value="advanced_mailer" />
|
||||||
<input type="hidden" name="act" value="procAdvanced_mailerAdminTestSendMail" />
|
<input type="hidden" name="act" value="procAdvanced_mailerAdminTestSendSMS" />
|
||||||
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
|
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
|
||||||
|
|
||||||
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||||
|
|
@ -13,19 +13,22 @@
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
|
|
||||||
<h2>{$lang->cmd_advanced_mailer_mail_test}</h2>
|
<h2>{$lang->cmd_advanced_mailer_sms_test}</h2>
|
||||||
|
|
||||||
<div class="x_control-group">
|
<div class="x_control-group">
|
||||||
<label class="x_control-label" for="advanced_mailer_recipient_name">{$lang->cmd_advanced_mailer_recipient_name}</label>
|
<label class="x_control-label" for="advanced_mailer_recipient_number">{$lang->cmd_advanced_mailer_recipient_number}</label>
|
||||||
<div class="x_controls">
|
<div class="x_controls">
|
||||||
<input type="text" id="advanced_mailer_recipient_name" value="{Context::get('logged_info')->nick_name}" />
|
<input type="text" id="advanced_mailer_recipient_number" value="{config('sms.default_from')}" />
|
||||||
|
{$lang->cmd_advanced_mailer_country_code}
|
||||||
|
<input type="number" id="advanced_mailer_country_code" value="" />
|
||||||
|
<p class="x_help-block">{$lang->cmd_advanced_mailer_country_code_help}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="x_control-group">
|
<div class="x_control-group">
|
||||||
<label class="x_control-label" for="advanced_mailer_recipient_email">{$lang->cmd_advanced_mailer_recipient_email}</label>
|
<label class="x_control-label" for="advanced_mailer_content">{$lang->cmd_advanced_mailer_status_content}</label>
|
||||||
<div class="x_controls">
|
<div class="x_controls">
|
||||||
<input type="text" id="advanced_mailer_recipient_email" value="{Context::get('logged_info')->email_address}" />
|
<textarea id="advanced_mailer_content">{$lang->cmd_advanced_mailer_test_content}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -39,7 +42,7 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="btnArea x_clearfix">
|
<div class="btnArea x_clearfix">
|
||||||
<button id="advanced_mailer_test_send_mail" type="submit" class="x_btn x_btn-primary x_pull-right">{$lang->cmd_advanced_mailer_send}</button>
|
<button id="advanced_mailer_test_send_sms" type="submit" class="x_btn x_btn-primary x_pull-right">{$lang->cmd_advanced_mailer_send}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue