mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 07:12: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()
|
||||
{
|
||||
|
|
@ -250,23 +250,23 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
|||
|
||||
if (!$result)
|
||||
{
|
||||
if (count($oMail->errors))
|
||||
if (count($oMail->getErrors()))
|
||||
{
|
||||
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'));
|
||||
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'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->errors))));
|
||||
$this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->getErrors()))));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
|
@ -285,4 +285,56 @@ class Advanced_MailerAdminController extends Advanced_Mailer
|
|||
$this->add('test_result', Context::getLang('msg_advanced_mailer_test_success'));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue