[AIX 네트워크 관리 5] 메일 (4) sendmail 관리: 별칭, 메일 큐, 로그

핵심 정리

  • 메일 관리자의 일: /etc/rc.tcpip에서 sendmail 시작, /etc/mail/sendmail.cf 구성(기본은 로컬·TCP/IP 메일, BNU는 고쳐야 함), /etc/mail/aliases 별칭, 메일 큐와 로그 관리.
  • /etc/mail/aliases는 별칭: 이름1, 이름2, … 형식이며 MAILER-DAEMON, postmaster, nobody 세 별칭이 꼭 있어야 합니다. 고친 뒤에는 sendmail -bi나 newaliases로 /etc/mail/aliases.db를 다시 만듭니다. 오류를 받을 소유자는 owner-별칭: 주소로 지정합니다. NIS 별칭은 /etc/netsvc.conf에 aliases=files, nis.
  • 메일 큐는 /var/spool/mqueue이며 mailq(=sendmail -bp)로 봅니다. 큐 파일은 df(본문)·qf(제어)·tf(임시)·xf(기록) + 큐 ID입니다.
  • 큐 처리 간격은 -q시간(s·m·h·d·w, 기본 단위 분)이며 /etc/rc.tcpip의 qpi 변수(기본 30m)로 정합니다. 막힌 큐는 sendmail -q -v, 특정 수신자만 -qR문자열. 큐가 너무 크면 디렉터리를 옮기고 sendmail -oQ/var/spool/omqueue -q로 따로 처리합니다.
  • 시작·정지: startsrc -s sendmail -a "-bd -q15", stopsrc -s sendmail. 로그는 syslog의 mail.debug /var/spool/mqueue/log로 받고 /usr/lib/smdemon.cleanu로 돌립니다. /etc/mail/statistics를 만들면 mailstats로 메일러별 통계를 봅니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (5.3판의 'AIX 5.1 이전' 참고가 6.1판에서 빠짐)
원문 Networks and communication management — 5.3판 4452쪽, 6.1판 4554쪽
파일 /etc/rc.tcpip, /etc/mail/sendmail.cf, /etc/mail/aliases, /etc/mail/aliases.db, /etc/netsvc.conf, /var/spool/mqueue, /var/spool/mqueue/log, /etc/syslog.conf, /etc/mail/statistics
관련 명령어 sendmail, newaliases, mailq, startsrc, stopsrc, refresh, mailstats, /usr/lib/smdemon.cleanu

메일 관리 작업

메일 관리자는 다음 작업을 맡습니다.

  1. 시스템 부팅 때 sendmail 데몬이 시작되도록 /etc/rc.tcpip 파일을 구성합니다. "sendmail 데몬을 시작하도록 /etc/rc.tcpip 파일 구성하기"를 봅니다.
  2. 구성 파일 /etc/mail/sendmail.cf를 고칩니다. 기본 /etc/mail/sendmail.cf 파일은 로컬 메일과 TCP/IP 메일을 모두 배달하도록 구성되어 있습니다. BNU로 메일을 배달하려면 /etc/mail/sendmail.cf 파일을 고쳐야 합니다. 자세한 내용은 Files Reference의 sendmail.cf File을 봅니다.
  3. 시스템 전체와 도메인 전체의 메일 별칭을 /etc/mail/aliases 파일에 정의합니다. "메일 별칭"을 봅니다.
  4. 메일 큐를 관리합니다. "메일 큐"를 봅니다.
  5. 메일 로그를 관리합니다. "메일 로그"를 봅니다.
영어 원문

Mail management tasks

The mail manager is responsible for these tasks.

  1. Configure the /etc/rc.tcpip file so that the sendmail daemon will be started at system boot time. See “Configuring the /etc/rc.tcpip file to start the sendmail daemon.”

  2. Customize the configuration file /etc/mail/sendmail.cf. The default /etc/mail/sendmail.cf file is configured so that both local mail and TCP/IP mail can be delivered. In order to deliver mail through BNU, you must customize the /etc/mail/sendmail.cf file. See the sendmail.cf File in Files Reference for more information.

  3. Define system-wide and domain-wide mail aliases in the /etc/mail/aliases file. See “Mail aliases” for more information.

  4. Manage the Mail Queue. See Mail queue for more information.

  5. Manage the Mail Log. See Mail logging for more information.

sendmail 데몬을 시작하도록 /etc/rc.tcpip 파일 구성하기

시스템 부팅 때 sendmail 데몬이 시작되도록 /etc/rc.tcpip 파일을 구성하는 절차입니다.

  1. 즐겨 쓰는 텍스트 편집기로 /etc/rc.tcpip 파일을 편집합니다.
  2. start /usr/lib/sendmail로 시작하는 줄을 찾습니다. 기본으로 이 줄은 주석 처리되어 있지 않아야 합니다. 곧 줄 맨 앞에 #(파운드 기호)가 없어야 합니다. 주석 처리되어 있으면 파운드 기호를 지웁니다.
  3. 파일을 저장합니다.

이렇게 바꾸면 시스템이 부팅 때 sendmail 데몬을 시작합니다.

영어 원문

Configuring the /etc/rc.tcpip file to start the sendmail daemon

To configure the /etc/rc.tcpip file so that the sendmail daemon will be started at system boot time, use this procedure.

  1. Edit the /etc/rc.tcpip file with your favorite text editor.

  2. Find the line that begins with start /usr/lib/sendmail. By default, this line should be uncommented, that is, there is no # (pound sign) at the beginning of the line. However, if it is commented, delete the pound sign.

  3. Save the file.

With this change, the system will start the sendmail daemon at boot time.

메일 별칭

별칭(alias)은 개인, 시스템 전체, 도메인 전체 별칭 파일로 이름을 주소 목록에 대응시킵니다.

별칭은 세 종류를 정의할 수 있습니다.

종류 설명
개인(personal) 사용자가 자기 $HOME/.mailrc 파일에 정의합니다.
로컬 시스템(local system) 메일 시스템 관리자가 /etc/mail/aliases 파일에 정의합니다. 로컬 시스템의 sendmail 프로그램이 처리하는 메일에 적용됩니다. 로컬 시스템 별칭은 거의 바꿀 일이 없습니다.
도메인 전체(domainwide) 기본으로 sendmail은 별칭을 풀 때 /etc/alias를 읽습니다. 기본값 대신 NIS를 쓰려면 /etc/netsvc.conf를 편집하거나 만들어 aliases=nis 줄을 넣습니다.
영어 원문

Mail aliases

Aliases map names to address lists using personal, system-wide, and domain-wide alias files.

You can define three types of aliases:

  • personal — Defined by individual users in the user's $HOME/.mailrc file.
  • local system — Defined by the mail system administrator in the /etc/mail/aliases file. These aliases apply to mail handled by the sendmail program on the local system. Local system aliases rarely need to be changed.
  • domainwide — By default, sendmail reads /etc/alias to resolve aliases. To override the default and use NIS, edit or create /etc/netsvc.conf and add the line: aliases=nis

/etc/mail/aliases 파일

/etc/mail/aliases 파일의 속성, 내용, 위치를 설명합니다.

/etc/mail/aliases 파일은 다음 형식의 항목들로 이루어집니다.

text
Alias : Name1 , Name2 , ... NameX

Alias는 내가 고르는 영숫자 문자열(@나 ! 같은 특수 문자는 제외)입니다. Name1부터 NameX까지는 받는 사람 이름 하나 이상입니다. 이름 목록은 여러 줄에 걸칠 수 있으며, 이어지는 줄은 공백이나 탭으로 시작합니다. 빈 줄과 #(파운드 기호)로 시작하는 줄은 주석입니다.

/etc/mail/aliases 파일에는 다음 세 별칭이 꼭 있어야 합니다.

별칭 설명
MAILER-DAEMON 메일러 데몬 앞으로 온 메시지를 받을 사용자 ID. 처음에는 root 사용자로 지정되어 있습니다: MAILER-DAEMON: root
postmaster 로컬 메일 시스템 운영을 맡은 사용자 ID. postmaster 별칭은 네트워크의 모든 시스템에서 유효한 메일함 주소 하나를 정합니다. 덕분에 사용자는 그 시스템의 다른 사용자 주소를 몰라도 어느 시스템의 postmaster 별칭으로든 문의를 보낼 수 있습니다. 처음에는 root 사용자로 지정되어 있습니다: postmaster: root
nobody news나 msgs 같은 프로그램 앞으로 온 메시지를 받을 ID. 처음에는 /dev/null로 지정되어 있습니다: nobody: /dev/null. 이 메시지를 받으려면 이 별칭을 올바른 사용자로 정의합니다.

이 파일을 바꿀 때마다 sendmail 명령이 쓸 수 있는 데이터베이스 형식으로 다시 컴파일해야 합니다. "별칭 데이터베이스 만들기"를 봅니다.

영어 원문

/etc/mail/aliases file

The properties, contents, and location of the /etc/mail/aliases file are described here.

The /etc/mail/aliases file consists of a series of entries in the following format:

text
Alias : Name1 , Name2 , ... NameX

where Alias can be any alphanumeric string that you choose (not including special characters, such as @ or !). Name1 through NameX is a series of one or more recipient names. The list of names can span one or more lines. Each continued line begins with a space or a tab. Blank lines and lines beginning with a # (pound sign) are comment lines.

The /etc/mail/aliases file must contain the following three aliases:

  • MAILER-DAEMON — The ID of the user who is to receive messages addressed to the mailer daemon. This name is initially assigned to the root user: MAILER-DAEMON: root
  • postmaster — The ID of the user responsible for the operation of the local mail system. The postmaster alias defines a single mailbox address that is valid at each system in a network. This address enables users to send inquiries to the postmaster alias at any system, without knowing the correct address of any user at that system. This name is initially assigned to the root user: postmaster: root
  • nobody — The ID that is to receive messages directed to programs such as news and msgs. This name is initially assigned to /dev/null: nobody: /dev/null To receive these messages, define this alias to be a valid user.

Whenever you change this file, you must recompile it into a database format that the sendmail command can use. See Alias database building.

로컬 메일 별칭 만들기

로컬 메일 별칭을 만들면 메일을 보낼 수 있는 그룹이나 배포 목록을 만들 수 있습니다.

이 예에서는 geo@medussa, mark@zeus, ctw@athena, dsf@plato를 testers 메일 별칭에 넣습니다. testers 별칭을 만든 뒤 glenda@hera에게 별칭의 소유권을 줍니다.

testers 별칭을 /etc/mail/aliases 파일에 넣은 뒤 sendmail 명령으로 별칭 데이터베이스를 다시 컴파일합니다. 데이터베이스를 다시 컴파일하면 testers 별칭으로 메일을 보낼 수 있습니다.

고려할 점

  • 이 따라 하기의 정보는 특정 AIX 버전으로 시험했습니다. AIX 버전과 수준에 따라 결과가 크게 다를 수 있습니다.

로컬 메일 별칭을 만드는 단계는 다음과 같습니다.

  1. 즐겨 쓰는 텍스트 편집기로 /etc/mail/aliases 파일을 엽니다.
  2. 빈 줄에 별칭 이름, 콜론, 쉼표로 구분한 받는 사람 목록을 넣습니다. 예를 들어 다음 항목은 testers 별칭을 정의합니다.
text
testers: geo@medussa, mark@zeus, ctw@athena, dsf@plato
  1. 별칭의 소유자를 만듭니다. sendmail 명령이 별칭으로 메일을 보내지 못하면 소유자에게 오류 메시지를 보냅니다. /etc/mail/aliases에 소유자를 지정하는 줄을 넣습니다. 형식은 owner-groupname: owner이며, groupname은 별칭 이름이고 owner는 소유자의 전자 우편 주소입니다. 이 예에서는 glenda@hera를 testers 별칭의 소유자로 합니다.
text
testers: geo@medussa, mark@zeus, ctw@athena, dsf@plato owner-testers: glenda@hera
  1. 별칭을 만든 뒤 sendmail -bi 명령으로 별칭 데이터베이스를 다시 컴파일합니다. /etc/mail/aliases 파일을 고칠 때마다 이 명령을 실행해야 합니다.

이제 testers 별칭으로 전자 우편을 보낼 수 있습니다.

영어 원문

Creating a local alias for mail

Creating local mail aliases allows you to create groups or distribution lists to which mail can be sent.

In this scenario, geo@medussa, mark@zeus, ctw@athena, and dsf@plato will be added to the testers mail alias. After the testers alias is created, glenda@hera will be given ownership of the alias.

After the testers alias is added to the /etc/mail/aliases file, the aliases database is recompiled using the sendmail command. After the database is recompiled, email can be sent to the testers alias.

Things to Consider

  • The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.

Use the following steps to create a local mail alias:

  1. Open the /etc/mail/aliases file using your favorite text editor.

  2. On a blank line, add the alias name, followed by a colon and a list of comma-separated recipients. For example, the following entry defines the testers alias:

text
testers: geo@medussa, mark@zeus, ctw@athena, dsf@plato
  1. Create an owner for the alias. If the sendmail command is unsuccessful in sending mail to the alias, it sends an error message to the owner. Add a line in the /etc/mail/aliases to specify the owner. The format for this line is owner-groupname: owner, where groupname is the name of the alias and owner is the e-mail address of the owner. In this example, glenda@hera is made the owner of the testers alias:
text
testers: geo@medussa, mark@zeus, ctw@athena, dsf@plato owner-testers: glenda@hera
  1. After the alias is created, run the sendmail -bi command to recompile the aliases database. You will need to run this command each time you update your /etc/mail/aliases file.

You can now send email to the testers alias.

별칭 데이터베이스 만들기

sendmail 명령은 로컬 시스템의 /etc/mail/aliases 파일에 있는 별칭 정의를 바로 쓰지 않습니다. 대신 /etc/mail/aliases 파일을 처리한 dbm(database manager) 버전을 읽습니다.

별칭 데이터베이스는 다음 가운데 한 방법으로 컴파일합니다.

  • /usr/sbin/sendmail 명령을 -bi 플래그로 실행합니다.
  • newaliases 명령을 실행합니다. 이 명령은 sendmail 명령이 로컬 시스템의 /etc/mail/aliases 파일을 읽고 별칭 데이터베이스 정보가 든 새 파일을 만들게 합니다. 이 파일은 더 효율적인 Berkeley 형식인 /etc/mail/aliases.db입니다.
  • sendmail 명령을 별칭 다시 만들기(Rebuild Aliases) 플래그로 실행합니다. 별칭 데이터베이스가 낡으면 자동으로 다시 만듭니다. 별칭 파일이 크고 부하가 많은 기계에서는 자동 재생성이 위험할 수 있습니다. 데이터베이스를 다시 만드는 데 재생성 시간 초과(보통 5분)보다 오래 걸리면 여러 프로세스가 동시에 재생성을 시작할 수 있습니다.

참고

  1. 이 파일들이 없으면 sendmail 명령은 메일을 처리하지 못하고 오류 메시지를 냅니다.
  2. 별칭 데이터베이스를 여러 개 지정했으면 -bi 플래그는 자기가 아는 데이터베이스 유형을 모두 다시 만듭니다(예를 들어 NDBM(Network Database Management) 데이터베이스는 다시 만들지만 NIS 데이터베이스는 못 만듭니다).

/etc/netsvc.conf 파일에는 시스템 서비스의 순서가 들어 있습니다. 별칭의 서비스 순서를 지정하려면 다음 줄을 넣습니다.

text
aliases=service, service

service는 files나 nis입니다. 예:

text
aliases=files, nis

이렇게 하면 sendmail 명령이 로컬 별칭 파일을 먼저 찾고, 실패하면 nis를 찾습니다. nis를 서비스로 정의했으면 NIS가 실행 중이어야 합니다.

/etc/netsvc.conf 파일에 관한 자세한 내용은 Files Reference를 봅니다.

영어 원문

Alias database building

The sendmail command does not use directly the alias definitions in the local system /etc/mail/aliases file. Instead, the sendmail command reads a processed database manager (dbm) version of the /etc/mail/aliases file.

You can compile the alias database using one of the following methods:

  • Run the /usr/sbin/sendmail command using the -bi flag.

  • Run the newaliases command. This command causes the sendmail command to read the local system /etc/mail/aliases file and create a new file containing the alias database information. This file is in the more efficient Berkeley format: /etc/mail/aliases.db

  • Run the sendmail command using the Rebuild Aliases flag. This rebuilds the alias database automatically when it is out-of-date. Auto-rebuild can be dangerous on heavily loaded machines with large alias files. If it might take more than the rebuild timeout (normally five minutes) to rebuild the database, there is a chance that several processes will start the rebuild process simultaneously.

Note

  1. If these files do not exist, the sendmail command cannot process mail and will generate an error message.

  2. If you have multiple alias databases specified, the -bi flag rebuilds all the database types it understands (for example, it can rebuild Network Database Management (NDBM) databases but not NIS databases).

The /etc/netsvc.conf file contains the ordering of system services. To specify the service ordering of aliases, add the following line:

text
aliases=service, service

where service can be either files or nis. For example:

text
aliases=files, nis

tells the sendmail command to try the local alias file first; and if that fails, try nis. If nis is defined as a service, it should be running.

For further information on the /etc/netsvc.conf file, see Files Reference.

메일 큐

메일 큐는 sendmail 명령이 배달하는 메일 메시지의 데이터와 제어 파일을 저장하는 디렉터리입니다. 기본 메일 큐는 /var/spool/mqueue입니다.

메일 메시지가 큐에 들어가는 이유는 여러 가지입니다. 예를 들면 다음과 같습니다.

  1. sendmail 명령이 큐를 바로 처리하지 않고 일정 간격으로 처리하도록 구성할 수 있습니다. 그러면 메일 메시지를 잠시 저장해야 합니다.
  2. 원격 호스트가 메일 연결 요청에 응답하지 않으면 메일 시스템이 메시지를 큐에 넣고 나중에 다시 시도합니다.
영어 원문

Mail queue

The mail queue is a directory that stores data and controls files for mail messages that the sendmail command delivers. By default, the mail queue is /var/spool/mqueue.

Mail messages might be queued for many reasons.

For example:

  1. The sendmail command can be configured to process the queue at certain intervals, rather than immediately. If this is so, mail messages must be stored temporarily.

  2. If a remote host does not answer a request for a mail connection, the mail system queues the message and tries again later.

메일 큐 출력

큐의 내용은 mailq 명령(또는 sendmail 명령에 -bp 플래그)으로 출력할 수 있습니다.

이 명령들은 큐 ID, 메시지 크기, 메시지가 큐에 들어온 날짜, 보낸 사람과 받는 사람의 목록을 보여 줍니다.

영어 원문

Mail queue printing

The contents of the queue can be printed using the mailq command (or by specifying the -bp flag with the sendmail command).

These commands produce a listing of the queue IDs, the sizes of the messages, the dates the messages entered the queue, and the senders and recipients.

메일 큐 파일

큐의 메시지마다 여러 파일이 붙어 있습니다. 파일 이름 규칙은 다음과 같습니다.

text
Type f ID

ID는 고유한 메시지 큐 ID이고, Type은 파일 종류를 나타내는 다음 글자 가운데 하나입니다.

Type 설명
d 머리글 정보 없이 메시지 본문이 든 데이터 파일
q 큐 제어 파일. 작업을 처리하는 데 필요한 정보가 들어 있습니다.
t 임시 파일. q 파일을 다시 만들 때의 이미지이며, 곧바로 q 파일로 이름이 바뀝니다.
x 세션 동안 존재하며 그 세션에서 일어난 모든 일을 보여 주는 기록(transcript) 파일

예를 들어 큐 ID가 AA00269인 메시지는 sendmail 명령이 배달하려는 동안 메일 큐 디렉터리에 다음 파일이 만들어지고 지워집니다.

파일 종류
dfAA00269 데이터 파일
qfAA00269 제어 파일
tfAA00269 임시 파일
xfAA00269 기록 파일

q 제어 파일

q 제어 파일은 줄마다 코드 글자로 시작하는 여러 줄로 이루어집니다.

코드 설명
B 본문 유형(body type)을 지정합니다. 줄의 나머지는 본문 유형을 정하는 문자열입니다. 이 필드가 아예 없으면 본문 유형은 기본 7비트이며 특별한 처리를 하지 않습니다. 올바른 값은 7BIT와 8BITMIME입니다.
C 제어 사용자. 받는 주소가 파일이나 프로그램이면 sendmail은 그 파일이나 프로그램의 소유자로 배달하며, 제어 사용자는 그 소유자로 설정됩니다. .forward나 :include: 파일에서 읽은 받는 주소도 제어 사용자가 그 파일의 소유자로 설정됩니다. sendmail은 이런 받는 사람에게 메일을 배달할 때 제어 사용자로 배달한 다음 다시 root로 돌아옵니다.
F 봉투(envelope) 플래그. EF_WARNING을 설정하는 w, EF_RESPONSE를 설정하는 r, EF_HAS8BIT을 설정하는 8, EF_DELETE_BCC를 설정하는 b를 조합합니다. 다른 글자는 소리 없이 무시합니다.
H 머리글 정의. 이 줄은 몇 개든 있을 수 있으며, H 줄의 순서가 최종 메시지에서 머리글의 순서가 됩니다. /etc/mail/sendmail.cf 구성 파일의 머리글 정의와 같은 구문을 씁니다.
I df 파일의 inode와 장치 정보. 디스크 고장 뒤 메일 큐를 복구하는 데 쓸 수 있습니다.
K 마지막 배달 시도 시각(초)
M 배달 시도 중 오류가 나서 메시지가 큐에 들어가면 오류의 성격을 M 줄에 저장합니다.
N 배달 시도 총횟수
O ESMTP의 원래 메시지 전송 시스템(MTS) 값. 배달 상태 알림(DSN)에만 씁니다.
P 현재 메시지의 우선순위. 큐의 순서를 정하는 데 씁니다. 숫자가 클수록 우선순위가 낮습니다. 메시지가 큐에 오래 있을수록 우선순위 값이 커집니다. 처음 우선순위는 메시지 클래스와 크기에 따라 정해집니다.
Q ESMTP 트랜잭션의 ORCPT= 필드로 지정한 원래 받는 사람. 배달 상태 알림에만 쓰며, 바로 다음 R 줄에만 적용됩니다.
R 받는 사람 주소. 받는 사람마다 한 줄씩 있습니다.
S 보낸 사람 주소. 이 줄은 하나만 있습니다.
T 메시지를 만든 시각. 메시지 시간 초과를 계산하는 데 씁니다.
V 큐 파일 형식의 버전 번호. 새 sendmail 바이너리가 이전 버전이 만든 큐 파일을 읽을 수 있게 합니다. 기본값은 0이며, 있으면 파일의 첫 줄이어야 합니다.
Z (ESMTP 트랜잭션의) 원래 봉투 ID. 배달 상태 알림에만 씁니다.
$ 매크로 정의. 일부 매크로($r, $s)의 값이 큐 실행 단계로 넘어갑니다.

amy@zeus에게 보낸 메시지의 q 파일은 다음과 비슷합니다.

text
P217031
T566755281
MDeferred: Connection timed out during user open with zeus
Sgeo
Ramy@zeus
H?P?return-path: <geo>
Hreceived: by george (0.13 (NL support)/0.01)
        id AA00269; Thu, 17 Dec 87 10:01:21 CST
H?D?date: Thu, 17 Dec 87 10:01:21 CST
H?F?From: geo
Hmessage-id: <8712171601.AA00269@george>
HTo: amy@zeus
Hsubject: test
줄 뜻
P217031 메시지의 우선순위
T566755281 제출 시각(초)
MDeferred: Connection timed out during user open with zeus 상태 메시지
Sgeo 보낸 사람의 ID
Ramy@zeus 받는 사람의 ID
H 줄 메시지의 머리글 정보
영어 원문

Mail queue files

Each message in the queue has a number of files associated with it.

The files are named according to the following conventions:

text
Type f ID

where ID is a unique message queue ID, and Type is one of the following letters indicating the type of file:

  • d — The data file containing the message body without the heading information.
  • q — The queue-control file. This file contains the information necessary to process the job.
  • t — A temporary file. This file is an image of the q file when it is being rebuilt. It is quickly renamed to the q file.
  • x — A transcript file that exists during the life of a session and shows everything that happens during that session.

For example, if a message has a queue ID of AA00269, the following files are created and deleted in the mail queue directory while the sendmail command tries to deliver the message:

  • dfAA00269 — Data file
  • qfAA00269 — Control file
  • tfAA00269 — Temporary file
  • xfAA00269 — Transcript file

q control file

The q control file contains a series of lines, each beginning with a code letter.

  • B — Specifies the body type. The remainder of the line is a text string defining the body type. If this entire field is missing, the body type is 7-bit by default, and no special processing is attempted. Legal values are 7BIT and 8BITMIME.
  • C — Contains the controlling user. For recipient addresses that are a file or a program, sendmail performs delivery as the owner of the file or program. The controlling user is set to the owner of the file or program. Recipient addresses that are read from a .forward or :include: file will also have the controlling user set to the owner of the file. When sendmail delivers mail to these recipients, it delivers as the controlling user, then converts back to root.
  • F — Contains envelope flags. The flags are any combination of w, which sets the EF_WARNING flag; r, which sets the EF_RESPONSE flag; 8, which sets the EF_HAS8BIT flag; and b, which sets the EF_DELETE_BCC flag. Other letters are silently ignored.
  • H — Contains a heading definition. There can be any number of these lines. The order in which the H lines appear determines their order in the final message. These lines use the same syntax as heading definitions in the /etc/mail/sendmail.cf configuration file.
  • I — Specifies the inode and device information for the df file; this can be used to recover your mail queue after a disk crash.
  • K — Specifies the time (as seconds) of the last delivery attempt.
  • M — When a message is put into the queue because an error occurred during a delivery attempt, the nature of the error is stored in the M line.
  • N — Specifies the total number of delivery attempts.
  • O — Specifies the original message transfer system (MTS) value from the ESMTP. It is used for Delivery Status Notifications only.
  • P — Contains the priority of the current message. The priority is used to order the queue. Higher numbers mean lower priorities. The priority increases as the message sits in the queue. The initial priority depends on the message class and the size of the message.
  • Q — Contains the original recipient as specified by the ORCPT= field in an ESMTP transaction. Used exclusively for Delivery Status Notifications. It applies only to the immediately following R line.
  • R — Contains a recipient address. There is one line for each recipient.
  • S — Contains the sender address. There is only one of these lines.
  • T — Contains the message creation time used to compute when to time out the message.
  • V — Specifies the version number of the queue file format used to allow new sendmail binaries to read queue files created by older versions. Defaults to version zero. Must be the first line of the file, if present.
  • Z — Specifies the original envelope ID (from the ESMTP transaction). Used for Delivery Status Notifications only.
  • $ — Contains a macro definition. The values of certain macros ($r and $s) are passed through to the queue run phase.

The q file for a message sent to amy@zeus would look similar to:

(13줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Where:

  • P217031 — Priority of the message
  • T566755281 — Submission time in seconds
  • MDeferred: Connection timed out during user open with zeus — Status message
  • Sgeo — ID of the sender
  • Ramy@zeus — ID of the receiver
  • H lines — Header information for the message

sendmail의 시간 값

메시지 시간 초과와 큐 처리 간격을 설정하려면 시간 값을 정해진 형식으로 써야 합니다. 형식은 다음과 같습니다.

text
-q NumberUnit

Number는 정수이고 Unit은 단위 글자입니다. Unit은 다음 가운데 하나입니다.

Unit 단위
s 초
m 분
h 시간
d 일
w 주

Unit을 지정하지 않으면 sendmail 데몬은 분(m)을 기본으로 씁니다. 시간 값을 지정하는 세 가지 예입니다.

text
/usr/sbin/sendmail -q15d

이 명령은 sendmail 데몬이 15일마다 큐를 처리하게 합니다.

text
/usr/sbin/sendmail -q15h

이 명령은 sendmail 데몬이 15시간마다 큐를 처리하게 합니다.

text
/usr/sbin/sendmail -q15

이 명령은 sendmail 데몬이 15분마다 큐를 처리하게 합니다.

영어 원문

Time values in sendmail

To set the message timeout and queue processing interval, you must use a specific format for the time value.

The format of a time value is:

text
-q NumberUnit

where Number is an integer value and Unit is the unit letter. Unit can have one of the following values:

  • s — Seconds
  • m — Minutes
  • h — Hours
  • d — Days
  • w — Weeks

If Unit is not specified, the sendmail daemon uses minutes (m) as the default. Here are three examples illustrating time-value specification:

text
/usr/sbin/sendmail -q15d

This command tells the sendmail daemon to process the queue every 15 days.

text
/usr/sbin/sendmail -q15h

This command tells the sendmail daemon to process the queue every 15 hours.

text
/usr/sbin/sendmail -q15

This command tells the sendmail daemon to process the queue every 15 minutes.

막힌 메일 큐

어떤 이유로 큐가 막힐 수 있습니다. -q 플래그(값 없이)로 큐를 강제로 실행할 수 있습니다.

-v(verbose) 플래그로 무슨 일이 일어나는지 볼 수도 있습니다.

text
/usr/sbin/sendmail -q -v

큐 수식자(modifier)로 특정 큐 식별자, 보낸 사람, 받는 사람의 작업만 처리하게 할 수도 있습니다. 예를 들어 -qRsally는 받는 사람 주소 가운데 하나에 sally 문자열이 든 작업만 큐에서 실행합니다. 마찬가지로 -qS문자열은 특정 보낸 사람으로, -qI문자열은 특정 큐 식별자로 실행을 제한합니다.

영어 원문

Clogged mail queues

In some cases, you might find that the queue is clogged for some reason. You can force a queue to run using the -q flag (with no value).

You can also use the -v flag (verbose) to watch what happens:

text
/usr/sbin/sendmail -q -v

You can also limit the jobs to those with a particular queue identifier, sender, or recipient using one of the queue modifiers. For example, -qRsally restricts the queue run to jobs that have the string sally in one of the recipient addresses. Similarly, -qSstring limits the run to particular senders, and -qIstring limits it to particular queue identifiers.

큐 처리 간격 설정하기

데몬이 시작될 때 -q 플래그의 값이 sendmail 데몬이 메일 큐를 처리하는 간격을 정합니다.

sendmail 데몬은 보통 시스템 시작 때 /etc/rc.tcpip 파일이 시작합니다. /etc/rc.tcpip 파일에는 큐 처리 간격(QPI)이라는 변수가 있어, sendmail 데몬을 시작할 때 -q 플래그의 값으로 씁니다. qpi의 기본값은 30분입니다. 다른 큐 처리 간격을 지정하려면 다음과 같이 합니다.

  1. 즐겨 쓰는 편집기로 /etc/rc.tcpip 파일을 편집합니다.
  2. qpi 변수에 값을 주는 줄을 찾습니다. 예:
text
qpi=30m
  1. qpi 변수에 원하는 시간 값을 줍니다.

바꾼 내용은 다음 시스템 재시작 때 적용됩니다. 바로 적용하려면 sendmail 데몬을 멈추고 새 -q 플래그 값으로 다시 시작합니다. "sendmail 데몬 멈추기"와 "sendmail 데몬 시작하기"를 봅니다.

영어 원문

Setting the queue processing interval

The value of the -q flag when the daemon starts determines the interval at which the sendmail daemon processes the mail queue.

The sendmail daemon is usually started by the /etc/rc.tcpip file, at system startup. The /etc/rc.tcpip file contains a variable called the queue processing interval (QPI), which it uses to specify the value of the -q flag when it starts the sendmail daemon. By default, the value of qpi is 30 minutes. To specify a different queue processing interval:

  1. Edit the /etc/rc.tcpip file with your favorite editor.

  2. Find the line that assigns a value to the qpi variable, such as:

text
qpi=30m
  1. Change the value assigned to the qpi variable to the time value you prefer.

These changes will take effect at the next system restart. If you want the changes to take effect immediately, stop and restart the sendmail daemon, specifying the new -q flag value. See Stopping the sendmail daemon and Starting the sendmail daemon for more information.

메일 큐 옮기기

호스트가 오랫동안 내려가 있으면 그 호스트로(또는 그 호스트를 거쳐) 가는 메시지가 메일 큐에 많이 쌓일 수 있습니다. 그러면 sendmail 명령이 큐를 정렬하는 데 오래 걸려 시스템 성능이 크게 떨어집니다. 큐를 임시 장소로 옮기고 새 큐를 만들면, 옛 큐는 그 호스트가 돌아온 뒤에 처리할 수 있습니다.

큐를 임시 장소로 옮기고 새 큐를 만드는 절차입니다.

  1. "sendmail 데몬 멈추기"의 안내대로 sendmail 데몬을 멈춥니다.
  2. 다음을 입력해 큐 디렉터리 전체를 옮깁니다.
text
cd /var/spool
mv mqueue omqueue
  1. "sendmail 데몬 시작하기"의 안내대로 sendmail 데몬을 다시 시작합니다.
  2. 다음을 입력해 옛 메일 큐를 처리합니다.
text
/usr/sbin/sendmail -oQ/var/spool/omqueue -q

-oQ 플래그는 다른 큐 디렉터리를 지정합니다. -q 플래그는 큐의 모든 작업을 실행하라는 뜻입니다. 진행 상황을 보려면 -v 플래그를 씁니다.

참고: 이 작업은 시간이 걸릴 수 있습니다.

  1. 큐가 비면 다음을 입력해 로그 파일과 임시 디렉터리를 지웁니다.
text
rm /var/spool/omqueue/*
rmdir /var/spool/omqueue
영어 원문

Moving the mail queue

When a host goes down for an extended period, many messages routed to (or through) that host might be stored in your mail queue. As a result, the sendmail command spends a long time sorting the queue, severely degrading your system performance. If you move the queue to a temporary place and create a new queue, the old queue can be run later when the host returns to service.

To move the queue to a temporary place and create a new queue:

  1. Stop the sendmail daemon by following the instructions in Stopping the sendmail daemon.

  2. Move the entire queue directory by entering:

text
cd /var/spool
mv mqueue omqueue
  1. Restart the sendmail daemon by following the instructions in Starting the sendmail daemon.

  2. Process the old mail queue by entering:

text
/usr/sbin/sendmail -oQ/var/spool/omqueue -q

The -oQ flag specifies an alternate queue directory. The -q flag specifies to run every job in the queue. To get a report about the progress of the operation, use the -v flag.

Note: This operation can take some time.

  1. Remove the log files and the temporary directory when the queue is empty by entering:
text
rm /var/spool/omqueue/*
rmdir /var/spool/omqueue

sendmail 데몬 시작하기

sendmail 데몬을 시작하는 명령은 두 가지입니다. 다음 가운데 하나를 입력합니다.

text
startsrc -s sendmail -a "-bd -q15"
/usr/lib/sendmail -bd -q15

이 명령을 입력할 때 sendmail 데몬이 이미 실행 중이면 화면에 다음 메시지가 나옵니다.

text
The sendmail subsystem is already active. Multiple instances are not supported.

sendmail 데몬이 실행 중이 아니면 sendmail 데몬을 시작했다는 메시지가 나옵니다.

영어 원문

Starting the sendmail daemon

There are two commands that start the sendmail daemon.

To start the sendmail daemon, enter either of the following commands:

text
startsrc -s sendmail -a "-bd -q15"
/usr/lib/sendmail -bd -q15

If the sendmail daemon is already active when you enter one of these commands, you see the following message on the screen:

text
The sendmail subsystem is already active. Multiple instances are not supported.

If the sendmail daemon is not already active, then you see a message indicating that the sendmail daemon has been started.

sendmail 데몬 멈추기

sendmail 데몬을 멈추려면 stopsrc -s sendmail 명령을 실행합니다.

sendmail 데몬을 startsrc 명령으로 시작하지 않았다면 다음과 같이 합니다.

  • sendmail 프로세스 ID를 찾습니다.
  • kill sendmail_pid 명령을 입력합니다(sendmail_pid는 sendmail 프로세스의 ID).
영어 원문

Stopping the sendmail daemon

To stop the sendmail daemon, run the stopsrc -s sendmail command.

If the sendmail daemon was not started with the startsrc command:

  • Find the sendmail process ID.

  • Enter the kill sendmail_pid command (where sendmail_pid is the process ID of the sendmail process).

메일 로그

sendmail 명령은 syslogd 데몬으로 메일 시스템 활동을 기록합니다.

기록하려면 syslogd 데몬이 구성되어 실행 중이어야 합니다. 특히 /etc/syslog.conf 파일에 주석 처리되지 않은 다음 줄이 있어야 합니다.

text
mail.debug           /var/spool/mqueue/log

없으면 즐겨 쓰는 편집기로 이렇게 바꾸고, 경로 이름이 맞는지 확인합니다. syslogd 데몬이 실행 중일 때 /etc/syslog.conf 파일을 바꿨으면 명령줄에서 다음을 입력해 syslogd 데몬을 새로 고칩니다.

text
refresh -s syslogd

/var/spool/mqueue/log 파일이 없으면 다음 명령으로 만들어야 합니다.

text
touch /var/spool/mqueue/log

로그 파일의 메시지 형식은 다음과 같습니다.

시스템 로그의 줄마다 시각, 그 줄을 만든 기계의 이름(LAN을 거쳐 여러 기계에서 기록할 때를 위해), sendmail:이라는 단어, 메시지가 있습니다. 대부분의 메시지는 이름=값 쌍의 나열입니다.

메시지를 처리할 때 가장 흔히 기록되는 두 줄은 수신 줄과 배달 시도 줄입니다. 수신 줄은 메시지를 받았음을 기록하며 메시지마다 하나씩 있습니다. 일부 필드는 빠질 수 있습니다. 필드는 다음과 같습니다.

필드 설명
from 봉투의 보낸 사람 주소
size 메시지 크기(바이트)
class 메시지의 클래스(숫자 우선순위)
pri 처음 메시지 우선순위(큐 정렬에 씀)
nrcpts 이 메시지의 봉투 받는 사람 수(별칭과 전달을 적용한 뒤)
proto 메시지를 받는 데 쓴 프로토콜. 예: ESMTP, UUCP(UNIX-to-UNIX Copy Program)
relay 메시지를 보내 온 기계

배달 시도 줄은 배달을 시도할 때마다 기록됩니다(배달이 미뤄지거나 받는 사람이 여럿이면 메시지마다 여러 줄일 수 있습니다). 필드는 다음과 같습니다.

필드 설명
to 이 메일러로 가는 받는 사람의 쉼표 구분 목록
ctladdr 제어 사용자, 곧 배달에 쓰는 자격 증명의 사용자 이름
delay 메시지를 받은 때부터 배달한 때까지의 총지연
xdelay 이번 배달 시도에 걸린 시간
mailer 이 받는 사람에게 배달하는 데 쓴 메일러 이름
relay 이 받는 사람을 실제로 받아들인(또는 거부한) 호스트 이름
stat 배달 상태

기록할 수 있는 정보가 아주 많으므로 로그 파일은 여러 수준으로 나뉩니다. 가장 낮은 수준 1에서는 아주 드문 상황만 기록합니다. 가장 높은 수준에서는 사소한 이벤트까지 기록합니다. 관례상 수준 10 이하에 가장 쓸모 있는 정보가 기록됩니다. 64보다 큰 수준은 디버깅용으로 예약되어 있고, 11~64는 자세한(verbose) 정보용으로 예약되어 있습니다.

sendmail 명령이 로그 파일에 넣는 활동의 종류는 /etc/mail/sendmail.cf 파일의 L 옵션으로 지정합니다.

영어 원문

Mail logging

The sendmail command logs mail system activity through the syslogd daemon.

The syslogd daemon must be configured and running for logging to occur. Specifically, the /etc/syslog.conf file should contain the uncommented line:

text
mail.debug           /var/spool/mqueue/log

If it does not, use your favorite editor to make this change; be certain that the path name is correct. If you change the /etc/syslog.conf file while the syslogd daemon is running, refresh the syslogd daemon by typing the following command at a command line:

text
refresh -s syslogd

If the /var/spool/mqueue/log file does not exist, you must create it by typing the following command:

text
touch /var/spool/mqueue/log

Messages in the log file appear in the following format:

Each line in the system log consists of a time stamp, the name of the machine that generated it (for logging from several machines over the local area network), the word sendmail:, and a message. Most messages are a sequence of name=value pairs.

The two most common lines logged when a message is processed are the receipt line and the delivery attempt line. The receipt line logs the receipt of a message; there will be one of these per message. Some fields may be omitted. These message fields are:

  • from — Specifies the envelope sender address.
  • size — Specifies the size of the message in bytes.
  • class — Indicates the class (numeric precedence) of the message.
  • pri — Specifies the initial message priority (used for queue sorting).
  • nrcpts — Indicates the number of envelope recipients for this message (after aliasing and forwarding).
  • proto — Specifies the protocol used to receive the message, for example ESMTP or UNIX-to-UNIX Copy Program (UUCP).
  • relay — Specifies the machine from which it was received.

The delivery attempt line is logged each time there is delivery attempt (so there can be several per message if delivery is deferred or there are multiple recipients). These fields are:

  • to — Contains a comma-separated list of the recipients to this mailer.
  • ctladdr — Specifies the controlling user, that is, the name of the user whose credentials are used for delivery.
  • delay — Specifies the total delay between the time this message was received and the time it was delivered.
  • xdelay — Specifies the amount of time needed in this delivery attempt.
  • mailer — Specifies the name of the mailer used to deliver to this recipient.
  • relay — Specifies the name of the host that actually accepted (or rejected) this recipient.
  • stat — Specifies the delivery status.

Because such a large amount of information can be logged, the log file is arranged as a succession of levels. Beginning at level 1, the lowest level, only very unusual situations are logged. At the highest level, even the insignificant events are logged. As a convention, log levels ten and under the most useful information. Log levels above 64 are reserved for debugging purposes. Levels from 11-64 are reserved for verbose information.

The types of activities that the sendmail command puts into the log file are specified by the L option in the /etc/mail/sendmail.cf file.

로그 관리

정보가 계속 로그 끝에 덧붙으므로 파일이 아주 커질 수 있습니다. 또 오류 상황 때문에 메일 큐에 예상치 못한 항목이 생길 수 있습니다. 메일 큐와 로그 파일이 너무 커지지 않게 하려면 /usr/lib/smdemon.cleanu 셸 스크립트를 실행합니다.

이 스크립트는 sendmail 명령이 큐를 처리하게 하고, 점점 오래된 로그 파일 사본 네 개(log.0, log.1, log.2, log.3)를 유지합니다. 실행할 때마다 다음처럼 옮깁니다.

  • log.2 → log.3
  • log.1 → log.2
  • log.0 → log.1
  • log → log.0

이 스크립트를 실행하면 새 파일에서 기록을 다시 시작합니다. 손으로 실행하거나 cron 데몬으로 정해진 간격마다 실행합니다.

영어 원문

Log management

Because information is continually appended to the end of the log, the file can become very large. Also, error conditions can cause unexpected entries to the mail queue. To keep the mail queue and the log file from growing too large, run the /usr/lib/smdemon.cleanu shell script.

This script forces the sendmail command to process the queue and maintains four progressively older copies of log files, named log.0, log.1, log.2, and log.3. Each time the script runs it moves:

  • log.2 to log.3

  • log.1 to log.2

  • log.0 to log.1

  • log to log.0

Running this script allows logging to start over with a new file. Run this script either manually or at a specified interval with the cron daemon.

트래픽 로그

sendmail 명령의 -X 플래그로 트래픽 기록을 설정합니다.

많은 SMTP(Simple Mail Transfer Protocol) 구현이 프로토콜을 완전히 구현하지 않습니다. 예를 들어 어떤 PC 기반 SMTP는 응답 코드의 연속 줄을 이해하지 못합니다. 이런 문제는 추적하기가 아주 어렵습니다. 이런 문제가 의심되면 -X 플래그로 트래픽 기록을 설정합니다. 예:

text
/usr/sbin/sendmail -X /tmp/traffic -bd

이 명령은 모든 트래픽을 /tmp/traffic 파일에 기록합니다.

이 명령은 아주 빠르게 많은 데이터를 기록하므로 평소 운영 중에는 절대 쓰면 안 됩니다. 명령을 실행한 뒤, 문제가 있는 구현이 내 호스트로 메시지를 보내게 합니다. 들어오는 SMTP 트래픽을 포함해 sendmail을 드나드는 모든 메시지 트래픽이 이 파일에 기록됩니다.

sendmail에 SIGUSR1 신호를 보내면 열린 파일과 연결 캐시의 덤프를 기록할 수 있습니다. 결과는 LOG_DEBUG 우선순위로 기록됩니다.

영어 원문

Traffic logs

Use the -X flag of the sendmail command to set traffic logging.

Many Simple Mail Transfer Protocols (SMTPs) implementations do not fully implement the protocol. For example, some personal computer-based SMTPs do not understand continuation lines in reply codes. These can be very hard to trace. If you suspect such a problem, you can set traffic logging by using the

-X flag. For example

text
/usr/sbin/sendmail -X /tmp/traffic -bd

This command logs all traffic in the /tmp/traffic file.

Because this command logs a lot of data very quickly, it should never be used during normal operations. After running the command, force the errant implementation to send a message to your host. All message traffic in and out of sendmail, including the incoming SMTP traffic, will be logged in this file.

Using sendmail, you can log a dump of the open files and the connection cache by sending it a SIGUSR1 signal. The results are logged at LOG_DEBUG priority.

메일러 통계 로그

sendmail 명령은 자신과 연결된 메일러 프로그램마다 처리하는 메일의 양을 추적합니다. 그 메일러들은 /etc/mail/sendmail.cf 파일에 정의되어 있습니다.

(이 자리에 sendmail이 쓰는 메일러 그림이 있으며, 메일 (1)의 그림 2와 같습니다. Mail과 MH 아래에 bellmail, BNU, SMTP가 있고, 그 아래에 각각 로컬 메일함, UUCP 링크, TCP/IP 링크가 있으며, UUCP 링크와 TCP/IP 링크 아래에는 원격 메일함이 있습니다.)

메일러 통계를 모으기 시작하려면 다음을 입력해 /etc/mail/statistics 파일을 만듭니다.

text
touch /etc/mail/statistics

통계 정보를 기록하다 오류가 나면 sendmail 명령은 syslog 서브루틴으로 메시지를 씁니다. 이 오류는 sendmail 명령의 다른 동작에 영향을 주지 않습니다.

sendmail 명령은 메일을 처리할 때마다 이 파일의 정보를 갱신합니다. 파일 크기는 늘지 않지만 파일의 숫자는 커집니다. 이 숫자는 /etc/mail/statistics 파일을 만들거나 초기화한 뒤의 메일 양을 나타냅니다.

영어 원문

Mailer statistics logs

The sendmail command tracks the volume of mail being handled by each of the mailer programs that interface with it.

Those mailers are defined in the /etc/mail/sendmail.cf file.

This illustration is a type of top-down organizational chart with Mail and MH at the top. Branching from them are bellmail, BNU and SMTP. Underneath the previous level are local mailbox, UUCP link, and TCP/IP link respectively. Beneath UUCP link is remote mailbox and under TCP/IP link is remote mailbox.

To start the accumulation of mailer statistics, create the /etc/mail/statistics file by typing the following:

text
touch /etc/mail/statistics

If the sendmail command encounters errors when trying to record statistics information, the command writes a message through the syslog subroutine. These errors do not affect other operations of the sendmail command.

The sendmail command updates the information in the file each time it processes mail. The size of the file does not grow, but the numbers in the file do. They represent the mail volume since the time you created or reset the /etc/mail/statistics file.

메일러 정보 보기

/etc/mail/statistics 파일에 저장된 통계는 텍스트 파일로 읽을 수 없는 데이터베이스 형식입니다.

메일러 통계를 보려면 명령 프롬프트에서 다음을 입력합니다.

text
/usr/sbin/mailstats

(그림 3. sendmail 명령이 쓰는 메일러 — 메일 (1)의 그림 2와 같음)

이 명령은 /etc/mail/statistics 파일의 정보를 읽어 서식화한 다음 표준 출력에 씁니다. /usr/sbin/mailstats 명령의 출력은 Commands Reference 3권의 설명을 봅니다.

영어 원문

Displaying mailer information

The statistics kept in the /etc/mail/statistics file are in a database format that cannot be read as a text file.

To display the mailer statistics, type the following at a command prompt:

text
/usr/sbin/mailstats

bellmail

local mailbox Mail MH

BNU SMTP

UUCP link TCP/IP link

remote mailbox remote mailbox sendmail

Figure 3. Mailers used by the sendmail command

This reads the information in the /etc/mail/statistics file, formats it, and writes it to standard output. For information on the output of the /usr/sbin/mailstats command, read its description in the Commands Reference, Volume 3.