데이터베이스 관리 · 2 min read · Oct 07, 2025

Postfix, Courier 및 MySQL을 이용한 가상 사용자 및 도메인 (Debian Etch) - 페이지 6

13 데이터베이스 채우기 및 테스트

데이터베이스를 채우기 위해 MySQL 셸을 사용할 수 있습니다:

mysql -u root -p  
 USE mail;

최소한 domainsusers 테이블에 항목을 생성해야 합니다:

INSERT INTO `domains` (`domain`) VALUES ('example.com');  
 INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('[email protected]', ENCRYPT('secret'), 10485760);

(비밀번호를 암호화하기 위해 두 번째 INSERT 문에서 ENCRYPT 구문을 사용해야 합니다!)

다른 두 테이블에 항목을 추가하고 싶다면, 다음과 같이 보일 것입니다:

INSERT INTO `forwardings` (`source`, `destination`) VALUES ('[email protected]', '[email protected]');  
 INSERT INTO `transport` (`domain`, `transport`) VALUES ('example.com', 'smtp:mail.example.com');

MySQL 셸을 종료하려면 다음을 입력하세요:

quit;

대부분의 사람들은 MySQL의 그래픽 프론트 엔드가 있는 것이 더 쉽습니다. 따라서 http://192.168.0.100/phpmyadmin/ 또는 http://server1.example.com/phpmyadmin/에서 phpMyAdmin을 사용하여 mail 데이터베이스를 관리할 수 있습니다. 다시 말하지만, 사용자를 생성할 때 비밀번호를 암호화하기 위해 ENCRYPT 함수를 사용하는 것을 잊지 마세요:

도메인 및 사용자 테이블에 대해 더 이상 설명할 필요는 없다고 생각합니다.

forwardings 테이블은 다음과 같은 항목을 가질 수 있습니다:

sourcedestination
[email protected][email protected][email protected]의 이메일을 [email protected]로 리디렉션합니다.
@example.com[email protected][email protected]에 대한 Catch-All 계정을 생성합니다. example.com으로 오는 모든 이메일은 [email protected]로 도착하며, users 테이블에 존재하는 이메일은 제외됩니다 (즉, [email protected]가 users 테이블에 존재하면 [email protected]로 오는 이메일은 여전히 [email protected]로 도착합니다).
@example.com@anotherdomain.tldexample.com으로 오는 모든 이메일을 anotherdomain.tld의 동일한 사용자에게 리디렉션합니다. 예를 들어, [email protected]로 오는 이메일은 [email protected]로 전달됩니다.
[email protected][email protected], [email protected][email protected]의 이메일을 두 개 이상의 이메일 주소로 전달합니다. destination 아래에 나열된 모든 이메일 주소는 이메일의 사본을 받습니다.

transport 테이블은 다음과 같은 항목을 가질 수 있습니다:

domaintransport
example.com:example.com의 이메일을 로컬로 전달합니다. 이 레코드가 이 테이블에 전혀 존재하지 않는 것과 같습니다.
example.comsmtp:mail.anotherdomain.tldexample.com의 모든 이메일을 smtp를 통해 mail.anotherdomain.com 서버로 전달합니다.
example.comsmtp:mail.anotherdomain.tld:2025example.com의 모든 이메일을 smtp를 통해 mail.anotherdomain.com 서버로 전달하지만, 기본 포트인 25가 아닌 포트 2025에서 전달합니다.

| example.com | smtp:[1.2.3.4]
smtp:[1.2.3.4]:2025
smtp:[mail.anotherdomain.tld] | 대괄호는 Postfix가 대괄호 안의 주소에 대한 MX DNS 레코드를 조회하지 않도록 합니다. IP 주소에 대해 의미가 있습니다. | | .example.com | smtp:mail.anotherdomain.tld | example.com의 모든 하위 도메인에 대한 메일은 mail.anotherdomain.tld로 전달됩니다. | | * | smtp:mail.anotherdomain.tld | 모든 이메일은 mail.anotherdomain.tld로 전달됩니다. | | [email protected] | smtp:mail.anotherdomain.tld | [email protected]의 이메일은 mail.anotherdomain.tld로 전달됩니다. |

자세한 내용은

man transport

을 참조하세요.

transport 테이블의 항목 순서가 중요하다는 점을 기억하세요! 항목은 위에서 아래로 순서대로 처리됩니다.

중요: Postfix는 transports에 대한 캐싱 메커니즘을 사용하므로, transport 테이블의 변경 사항이 적용되기까지 시간이 걸릴 수 있습니다. 즉시 적용되도록 하려면, transport 테이블에서 변경한 후 다음을 실행하세요:

postfix reload

14 참고자료

15 링크

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.