1. Go to this page and download the library: Download sendgo/symfony library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// SMS (90자 이하)
$sendgo->sms->sendSms([
'content' => '[Sendgo] 인증번호: 123456 (5분 이내 입력)',
'contacts' => [['contact' => '01012345678']],
]);
// LMS (장문, 2,000자 이하)
$sendgo->sms->sendLms([
'subject' => '[중요] 서비스 점검 안내',
'content' => "안녕하세요. 서비스 점검이 예정되어 있습니다.\n\n■ 일시: 2026-07-25 02:00 ~ 06:00\n■ 영향: 전체 서비스",
'contacts' => [['contact' => '01012345678']],
]);
// MMS (이미지 포함)
$sendgo->sms->sendMms([
'subject' => '[이벤트] 7월 특가',
'content' => '이번 달 특가 상품을 확인하세요!',
'contacts' => [['contact' => '01011111111'], ['contact' => '01022222222']],
]);
// src/Service/NotificationService.php
namespace App\Service;
use Psr\Log\LoggerInterface;
use Sendgo\Php\Sendgo;
use Sendgo\Php\Exception\SendgoException;
class NotificationService
{
public function __construct(
private Sendgo $sendgo,
private LoggerInterface $logger,
) {}
public function sendOrderConfirm(string $phone, string $orderNo, int $amount): void
{
$this->sendgo->alimtalk->send([
'templateCode' => 'ORDER_CONFIRM_001',
'contacts' => [
['contact' => $phone, 'var1' => $orderNo, 'var2' => number_format($amount) . '원'],
],
]);
}
public function sendVerificationCode(string $phone, string $code): void
{
try {
// 알림톡 우선, 실패 시 SMS 대체
$this->sendgo->alimtalk->send([
'templateCode' => 'VERIFY_CODE_001',
'replaceSms' => 'Y',
'smsContent' => "[인증] 인증번호: {$code} (5분 이내 입력)",
'contacts' => [['contact' => $phone, 'var1' => $code]],
]);
} catch (SendgoException $e) {
$this->logger->error('Sendgo 인증번호 발송 실패', [
'phone' => $phone,
'error_code' => $e->getErrorCode(),
'status' => $e->getStatusCode(),
]);
throw $e;
}
}
}
// src/Message/SendAlimtalkMessage.php
namespace App\Message;
class SendAlimtalkMessage
{
public function __construct(
public readonly string $templateCode,
public readonly array $contacts,
) {}
}
// src/MessageHandler/SendAlimtalkHandler.php
namespace App\MessageHandler;
use App\Message\SendAlimtalkMessage;
use Sendgo\Php\Sendgo;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
class SendAlimtalkHandler
{
public function __construct(private Sendgo $sendgo) {}
public function __invoke(SendAlimtalkMessage $message): void
{
$this->sendgo->alimtalk->send([
'templateCode' => $message->templateCode,
'contacts' => $message->contacts,
]);
}
}