달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
2014. 12. 10. 15:08

6/24~26 CentOS / SENDMAIL SERVER IT 스터디/리눅스 Cent OS2014. 12. 10. 15:08

 

[SENDMAIL SERVER] 

 

 

홈페이지  http://www.sendmail.org 

 

 

 

1. 패키지설치 

 

yum install sendmail sendmail-cf sendmail-devel sendmail-doc -y

 

yum remove -y sendmail* 

 

 

 

A(MUA)>MTA서버-x-MTA서버>B

spool                    <<반응    1. 유저x    2. 수신거부

임시저장디렉터리

 

 

<참고자료>

HELO 

일반적으로 도메인 이름을 사용하여 클라이언트 자체를 식별하기 위해 클라이언트에서 보냅니다

 

EHLO 

서버에서 ESMTP(Extended Simple Mail Transfer Protocol) 명령에 대한 자체 지원을 식별할  있도록 합니다.  

 

MAIL FROM 

메시지를 보낸 사람을 식별하며 MAIL FROM: 형식으로 사용됩니다

 

RCPT TO 

메시지 받는 사람을 식별하며 RCPT TO: 형식으로 사용됩니다

 

TURN 

클라이언트와 서버가 역할을 전환할  있으며  연결을 설정하지 않고 반대 방향으로 메일을 보낼  있습니다

 

ATRN  

ATRN(인증된 TURN) 명령은 하나 이상의 도메인을 매개 변수로 사용할  있습니다세션이 인증되지 않은 경우에는 ATRN 명령은 거부되어야 합니다

 

SIZE 

SMTP 서버에서 지원되는 최대 메시지 크기를 표시할  있는 메커니즘을 제공합니다호환 서버는 수락할  있는 최대 메시지 크기를 표시하는 크기 확장을 제공해야 합니다클라이언트에서는 서버가 표시하는 크기보다  메시지를 보낼  없습니다

 

ETRN 

SMTP 확장. ETRN 다른 서버에서 자체 전자 메일 메시지를 모두 보내도록 요청하기 위해 SMTP 서버가 보냅니다

 

PIPELINING 

 명령 이후 응답을 기다리지 않고 명령 스트림을 보낼  있습니다

 

CHUNKING 

DATA 명령을 대체하는 ESMTP 명령 명령은 SMTP 호스트가 데이터의 끝부분을 계속적으로 검사하지 않도록 BDAT 명령을 메시지의 전체 바이트 수가 포함된 인수와 함께 보냅니다받는 서버에서 메시지 바이트를 계산하고 메시지 크기가 BDAT 명령으로 보낸 값과 같은 경우 서버는 모든 메시지 데이터를 받았다고 가정합니다

 

DATA 

클라이언트에서 메시지 내용 전송을 초기화하기 위해 보냅니다

 

DSN 

배달 상태 알림을 사용할  있는 ESMTP 명령입니다

 

RSET 

전체 메시지 트랜잭션을 무효화하고 버퍼를 다시 설정합니다

 

VRFY 

사서함을 메시지 배달용으로 사용할  있는지 확인합니다예를 들어 vrfy ted 사용하여 로컬 서버에 Ted 사서함이 있는지 확인합니다 명령은 Exchange 구현  기본적으로 해제됩니다

 

HELP 

SMTP 서비스에서 지원하는 명령 목록을 반환합니다

 

QUIT 

세션을 종료합니다

 


 

 

 

 

 

 

 

2. 소스 컴파일 (sendmail.8.14.3.tar.gz) 

 

yum install openldap-devel cyrus-sasl-devel db4-devel tcp_wrappers-devel 

 

 

wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.14.3.tar.gz 

 

 

 

tar xvfz sendmail.8.14.3.tar.gz 

 

cd sendmail.8.14.3 

 

                                      그레이브 `````````````````````````````````````````````````` 

*사전작업있음            작은따옴표    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 

 

cat > devtools/Site/site.config.m4 

 

define(`confMAPDEF', `-DNEWDB -DNIS -DMAP_REGEX -DLDAPMAP') 

 

define(`confENVDEF', `-I/usr/include/db4 -I/usr/include/sasl -DXDEBUG=0 

-DTCPWRAPPERS -DSASL=2 -DSTARTTLS') 

 

define(`confLIBS', `-lnsl -lwrap -lldap -llber -lsasl2 -lcrypt -lssl -lcrypto 

-ldb-4.3') 

 

APPENDDEF(`conf_sendmail_ENVDEF', `-DSTARTTLS -DSASL -DFALSE=0 

-DTRUE=1') 

 

APPENDDEF(`conf_sendmail_LIBS', `-ssl -lcrypto -lsasl2') 

 

 

APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER') 

 

APPENDDEF(`conf_libmilter_ENVDEF', `-DMILTER') 

 

 

 

 

 

 

./configure 아님 --------> sh Build 명령으로 대체됨 

 

 

 

 

sendmail 데몬 

 

 

#!/bin/bash 

# sendmail      This shell script takes care of starting and stopping 

#               sendmail. 

# chkconfig: 2345 80 30 

# description: Sendmail is a Mail Transport Agent, which is the program \ 

#              that moves mail from one machine to another. 

# processname: sendmail 

# config: /etc/mail/sendmail.cf 

# pidfile: /var/run/sendmail.pid 

 

# Source function library. 

. /etc/rc.d/init.d/functions 

# Source networking configuration. 

. /etc/sysconfig/network 

 

# Source sendmail configureation. 

if [ -f /etc/sysconfig/sendmail ] ; then 

. /etc/sysconfig/sendmail 

else 

DAEMON=no 

QUEUE=1h 

fi 

 

# Check that networking is up. 

[ ${NETWORKING} = "no" ] && exit 0 

 

[ -f /usr/sbin/sendmail ] || exit 0 

 

RETVAL=0 

prog="sendmail" 

 

start() { 

    # Start daemons. 

    if [ "$DAEMON" = yes ];then 

echo -n $"Starting $prog: " 

/usr/bin/newaliases > /dev/null 2>&1 

if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then 

  make -C /etc/mail -s 

else 

  for i in virtusertable access domaintable mailertable ; do 

    if [ -f /etc/mail/$i ] ; then 

makemap hash /etc/mail/$i < /etc/mail/$i 

    fi 

  done 

fi 

daemon /usr/sbin/sendmail ${DAEMONOPTIONS:-} -bd \ 

$([ -n "$QUEUE" ] && echo -q$QUEUE) 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail 

if ! test -f /var/run/sm-client.pid ; then 

echo -n $"Starting sm-client: " 

touch /var/run/sm-client.pid 

chown smmsp:smmsp /var/run/sm-client.pid 

daemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \ 

$([ -n "$QUEUE" ] && echo -q$QUEUE) 

RETVAL=$? 

        echo 

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client 

        fi 

 

return $RETVAL 

    fi 

 

stop() { 

    # Stop daemons. 

    if [ "$DAEMON" = yes ];then 

echo -n $"Shutting down $prog: " 

killproc sendmail 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail 

if test -f /var/run/sm-client.pid ; then 

echo -n $"Shutting down sm-client: " 

killproc /usr/sbin/sendmail 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid 

[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client 

fi 

return $RETVAL 

    fi 

 

# See how we were called. 

case "$1" in 

  start) 

start 

;; 

  stop) 

stop 

;; 

  restart|reload) 

stop 

start 

RETVAL=$? 

;; 

  condrestart) 

if [ -f /var/lock/subsys/sendmail ]; then 

    stop 

    start 

    RETVAL=$? 

fi 

;; 

  status) 

status sendmail.sendma 

RETVAL=$? 

;; 

  *) 

echo $"Usage: $0 {start|stop|restart|condrestart|status}" 

exit 1 

esac 

 

exit $RETVAL 

 

 

---------------------------------------------------------------------------------------------- 

 

mkdir -p /usr/man/man1 /usr/man/man8 

 

useradd -d /dev/null -s /sbin/nologin smmsp 

 

 

sh Build install 

 

 

sendmail -d0.1 -dv < /dev/null           명령으로 설치 점검해준다. 

 

확인사항 ==> SASL v2와 STARTTLS가 있는지 확인해준다. 

 

 

 

*만약 위의 두 파일이 없다면 

 

cat > devtools/Site/site.config.m4   구문오류임 

 

------------------------------------------------- 

 

*/etc/mail 디렉토리에 빈파일 생성(메일데몬이 참조함) 

 

touch /etc/mail/local-host-names  

touch /etc/mail/trusted-users 

touch /etc/mail/access 

touch /etc/mail/mailertable 

touch /etc/mail/aliases 

 

 

 

* 스풀디렉토리와 저장 디렉토리 생성 

 

mkdir /var/spool/mail 

mkdir /var/spool/mqueue 

mkdir /var/spool/clientmqueue 

mkdir /var/log/mail 

 

touch /var/log/mail/statistics 

 

chmod 600 /var/log/mail/statistics 

chmod 770 /var/spool/clientmqueue 

chmod 700 /var/spool/mqueue 

 

chown root.mail /var/spool/mqueue/ 

chown smmsp.smmsp /var/spool/clientmqueue 

chown root.mail /var/spool/mail 

 

 

 

*/etc/init.d/sendmail 생성      메일 데몬 스크립트 작성 

 

#!/bin/bash 

# sendmail      This shell script takes care of starting and stopping 

#               sendmail. 

# chkconfig: 2345 80 30 

# description: Sendmail is a Mail Transport Agent, which is the program \ 

#              that moves mail from one machine to another. 

# processname: sendmail 

# config: /etc/mail/sendmail.cf 

# pidfile: /var/run/sendmail.pid 

 

# Source function library. 

. /etc/rc.d/init.d/functions 

# Source networking configuration. 

. /etc/sysconfig/network 

 

# Source sendmail configureation. 

if [ -f /etc/sysconfig/sendmail ] ; then 

. /etc/sysconfig/sendmail 

else 

DAEMON=no 

QUEUE=1h 

fi 

 

# Check that networking is up. 

[ ${NETWORKING} = "no" ] && exit 0 

 

[ -f /usr/sbin/sendmail ] || exit 0 

 

RETVAL=0 

prog="sendmail" 

 

start() { 

    # Start daemons. 

    if [ "$DAEMON" = yes ];then 

echo -n $"Starting $prog: " 

/usr/bin/newaliases > /dev/null 2>&1 

if test -x /usr/bin/make -a -f /etc/mail/Makefile ; then 

  make -C /etc/mail -s 

else 

  for i in virtusertable access domaintable mailertable ; do 

    if [ -f /etc/mail/$i ] ; then 

makemap hash /etc/mail/$i < /etc/mail/$i 

    fi 

  done 

fi 

daemon /usr/sbin/sendmail ${DAEMONOPTIONS:-} -bd \ 

$([ -n "$QUEUE" ] && echo -q$QUEUE) 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail 

if ! test -f /var/run/sm-client.pid ; then 

echo -n $"Starting sm-client: " 

touch /var/run/sm-client.pid 

chown smmsp:smmsp /var/run/sm-client.pid 

daemon --check sm-client /usr/sbin/sendmail -L sm-msp-queue -Ac \ 

$([ -n "$QUEUE" ] && echo -q$QUEUE) 

RETVAL=$? 

        echo 

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sm-client 

        fi 

 

return $RETVAL 

    fi 

 

stop() { 

    # Stop daemons. 

    if [ "$DAEMON" = yes ];then 

echo -n $"Shutting down $prog: " 

killproc sendmail 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail 

if test -f /var/run/sm-client.pid ; then 

echo -n $"Shutting down sm-client: " 

killproc /usr/sbin/sendmail 

RETVAL=$? 

echo 

[ $RETVAL -eq 0 ] && rm -f /var/run/sm-client.pid 

[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sm-client 

fi 

return $RETVAL 

    fi 

 

# See how we were called. 

case "$1" in 

  start) 

start 

;; 

  stop) 

stop 

;; 

  restart|reload) 

stop 

start 

RETVAL=$? 

;; 

  condrestart) 

if [ -f /var/lock/subsys/sendmail ]; then 

    stop 

    start 

    RETVAL=$? 

fi 

;; 

  status) 

status sendmail.sendma 

RETVAL=$? 

;; 

  *) 

echo $"Usage: $0 {start|stop|restart|condrestart|status}" 

exit 1 

esac 

 

exit $RETVAL 

 

저장. 

 

 

* /etc/mail/sendmail.mc    /etc/mail/sendmail.cf  파일 생성 

 

sendmail.mc는 샘플로 대체한다. 

sendmail.cf는 sendmail.mc 파일로 생성해준다. 

 

 

cd /etc/mail 

 

vi sendmail.mc 

 

Line2 수정 --> tar.gz 압축해제한 소스디렉토리 경로를 지정해준다. 

 

include(`/root/0624/sendmail-8.14.4/cf/m4/cf.m4')dnl 

 

 

------------------------------------------------ 

 

/etc/sysconfig/sendmail 파일 생성 

 

cat > /etc/sysconfig/sendmail 

DAEMON=yes 

QUEUE=1h 

 

------------------------------------------------- 

데몬 실행 

 

service sendmail start 

 

------------------------------------------------- 

 

동작 테스트 

 

telnet localhost 25 

 

help 

 

ehlo root 

 

MAIL FROM:<자기계정@naver.com> 

 

RCPT TOL<자기계정@nate.com> 

 

DATA 

보내는 메시지 작성 

 

QUIT 

 


:
Posted by God Seed