hook에서 add_event로 이메일을 보내려고 합니다.
global $member, $is_admin, $g5, $config;
이렇게 설정을 하고 아래와 같이 적용을 하면 메일 발송이 되지 않아요.
mailer($config['cf_admin_email_name'], $config['cf_admin_email'], $member['mb_email'], $subject, $content, 1);
아래와 같이 직접 적용을 하면 메일 발송이 됩니다.
mailer("관리자", "[email protected]", "[email protected]", $subject, $content, 1);
global 적용말고 hook에서 아래와 같은 값을 불러 오는 방법이 따로 있나요?
$config['cf_admin_email_name'], $config['cf_admin_email'], $member['mb_email'],
global $member, $is_admin, $g5, $config;
이렇게 설정을 하고 아래와 같이 적용을 하면 메일 발송이 되지 않아요.
mailer($config['cf_admin_email_name'], $config['cf_admin_email'], $member['mb_email'], $subject, $content, 1);
아래와 같이 직접 적용을 하면 메일 발송이 됩니다.
mailer("관리자", "[email protected]", "[email protected]", $subject, $content, 1);
global 적용말고 hook에서 아래와 같은 값을 불러 오는 방법이 따로 있나요?
$config['cf_admin_email_name'], $config['cf_admin_email'], $member['mb_email'],
답변 1개 / 댓글 1개
채택된 답변
+20 포인트
2026-06-28 (일) 09:49:59
실제 hook 콜백 함수 안에서는 별도 스코프가 되기 때문에 값이 안 잡힐 수 있습니다.
메일 발송 코드는 hook으로 실행되는 함수 안쪽에서 다시 global 선언 후 사용하시면 됩니다.
function my_send_mail_hook()
{
global $member, $config;
include_once(G5_LIB_PATH.'/mailer.lib.php');
$subject = '메일 제목';
$content = '메일 내용';
$to_email = isset($member['mb_email']) ? $member['mb_email'] : '';
if (!$to_email) {
return;
}
mailer(
$config['cf_admin_email_name'],
$config['cf_admin_email'],
$to_email,
$subject,
$content,
1
);
}
답변에 대한 댓글 1개
2026-06-28 (일) 10:10:48
답변을 작성하려면 로그인이 필요합니다.
잘됩니다.