Mail 서버구축
sendmail 설치
1. /usr/local/src 디렉토리로 이동후 wget 사용해서 sendmail 다운받고 해당디렉토리로 이동
[root@server114 ~]# cd /usr/local/src [root@server114 src]# cd sendmail-8.15.1 [root@server114 sendmail-8.15.1]# |
2. smtp 가 주석처리 돼있는지 확인해서 되어있으면 삭제 (왜? 이거뭔데??)
[root@server114 sendmail-8.15.1]# grep smtp /etc/services smtp 25/tcp mail smtp 25/udp mail smtps 465/tcp # SMTP over SSL (TLS) rsmtp 2390/tcp # RSMTP rsmtp 2390/udp # RSMTP |
3. make로 컴파일후 프로그램설치 (컴파일시 디렉토리가 없어서 에러남 그래서 디렉토리 먼저 만듬)
[root@server114 sendmail-8.15.1]# mkdir -p /usr/man/man8 [root@server114 sendmail-8.15.1]# mkdir -p /usr/man/man1
[root@server114 sendmail-8.15.1]# mkdir -p /usr/man/man5 [root@server114 sendmail-8.15.1]# make ......(컴파일목록) [root@server114 sendmail-8.15.1]# make install .......(설치목록) |
sendmail 설정파일 생성
4. 설정파일이 있는 디렉토리로 이동 후 리눅스버전이므로 sendmail.mc파일로 변경
[root@server114 sendmail-8.15.1]# cd cf/cf [root@server114 cf]# [root@server114 cf]# pwd /usr/local/src/sendmail-8.15.1/cf/cf [root@server114 cf]# mv generic-linux.mc sendmail.mc |
5. vi sendmail.mc 파일열어서 아래 나용 추가
(access.db, domainaliases.db등등 자동으로 생성하기 위함) 후, 설정파일 빌드
[root@server114 cf]# vi sendmail.mc FEATURE(access_db)dnl FEATURE(virtusertable, btree /etc/mail/domainaliases.db)dnl FEATURE(genericstable, btree /etc/mail/useraliases.db)dnl FEATURE(accept_unqualified_senders)dn [root@server114 cf]# sh Build sendmail.cf [root@server114 cf]# ls sendmail.cf sendmail.cf |
6. 설정파일 install 하면 /etc/mail 디렉토리로 이동됨
[root@server114 cf]# make install-cf ../../devtools/bin/install.sh -c -o root -g bin -m 0444 sendmail.cf /etc/mail/sendmail.cf ../../devtools/bin/install.sh -c -o root -g bin -m 0444 submit.cf /etc/mail/submit.cf You have new mail in /var/spool/mail/root [root@server114 cf]# ls /etc/mail access helpfile Makefile submit.cf virtusertable.db access.db local-host-names sendmail.cf submit.mc domaintable mailertable sendmail.mc trusted-users domaintable.db mailertable.db statistics virtusertable [root@server114 cf]# |
7. sendmail 중요 설정파일 생성 및 설정 (access)
[root@server114 mail]# vi access access는 sendmail의 접근을 제어하는 파일. # Check the /usr/share/doc/sendmail/README.cf file for a description 호스트나 도메일을 허용하는 의미는 RELAY. # of the format of this file. (search for access_db in that file) 반대는 REJECT. # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc # package. # # by default we allow relaying from localhost... Connect:localhost.localdomain RELAY Connect:localhost RELAY Connect:127.0.0.1 RELAY Connect:172.16.5.114 RELAY ~ |
8. sendmail 중요 설정파일 생성 및 설정 (aliases)
[root@server114 mail]# vi aliases webmaster: root
//aliases 설정파일은 특정 계정으로 메일을 보냈을 경우 그 계정으로 메일이 도 착하지 않고 이 파일에 지정된 다른 계정으로 메일이 전송될 수 있게 함.특정 사 용자에게 온 메일을 다른 사람에게 보내주거나 리스트를 작성해야 하는 경우에 사용되 는 파일. ex) admin 계정에게 보내는 메일 admin : Gz@ab.com, gz@abcd.com ex) manager계정으로 오는 메일을 webmaster와 root로 전달 manager : root, webmaster ex) manager 계정으로 오는 메일을 /etc/mailist/manager 파일에 계정들에게 전달 manager:: include:/etc/maillist/manager |
9. makemap이란 프로그램을 사용하여 Sendmail이 인식할 수 있는 DB 형태로 만듬
[root@server114 mail]# touch local-host-names //사용하고자 할 도메인 이름을 입력하면 사용할수있는데 [root@server114 mail]# 여기서는 빈 파일로 생성함. [root@server114 mail]# makemap hash access < access [root@server114 mail]# ls access.db access.db |
10. aliases.db 파일 생성하기위한 단계
[root@server114 mail]# mkdir -p /var/spool/mqueue [root@server114 mail]# chmod 755 /var/spool/mqueue [root@server114 mail]# newaliases [root@server114 mail]# ls aliases.db aliases.db |
11. sendmail 데몬시작
[root@server114 mail]# which sendmail /usr/sbin/sendmail [root@server114 mail]# /usr/sbin/sendmail -Ac -q1h // 중계용데몬 [root@server114 mail]# /usr/sbin/sendmail -bd -q1h // 제출용(수신용)데몬 [root@server114 mail]# [root@server114 mail]# [root@server114 mail]# ps -ef | grep -v grep | grep sendmail root 3130 1 0 19:15 ? 00:00:00 sendmail: accepting connections smmsp 3138 1 0 19:15 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/s pool/clientmqueue smmsp 8587 1 0 23:03 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/s pool/clientmqueue smmsp 8781 1 0 23:29 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/s pool/clientmqueue root 8784 1 0 23:29 ? 00:00:00 /usr/sbin/sendmail -bd -q1h
[root@server114 mail]# |
12. sendmail TEST 및 메일 로그 확인
[root@server114 mail]# telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Thu, 12 Feb 2015 23:32:51 +0900 mail from : ******@gmail.com 250 2.1.0 ****@gmail.com... Sender ok rcpt to : d****@gmail.com 250 2.1.5 ****@gmail.com... Recipient ok (will queue) subject : Test mail 500 5.5.1 Command unrecognized: "subject : Test mail" data 354 Enter mail, end with "." on a line by itself hello bye . 250 2.0.0 t1CEWprk008797 Message accepted for delivery quit 221 2.0.0 localhost.localdomain closing connection Connection closed by foreign host. [root@server114 mail]# [root@server114 mail]# cd /var/log [root@server114 log]# tail -f maillog Feb 12 23:30:26 server114 sendmail[8784]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use Feb 12 23:30:26 server114 sendmail[8784]: daemon MTA: problem creating SMTP socket Feb 12 23:30:31 server114 sendmail[8784]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use Feb 12 23:30:31 server114 sendmail[8784]: daemon MTA: problem creating SMTP socket Feb 12 23:30:36 server114 sendmail[8784]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use Feb 12 23:30:36 server114 sendmail[8784]: daemon MTA: problem creating SMTP socket Feb 12 23:30:36 server114 sendmail[8784]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: server SMTP socket wedged: exiting Feb 12 23:33:19 server114 sendmail[8797]: t1CEWprk008797: Authentication-Warning: localhost.localdomain: server114 [127.0.0.1] didn't use HELO protocol Feb 12 23:34:16 server114 sendmail[8797]: t1CEWprk008797: from=****@gmail.com, size=10, class=0, nrcpts=1, msgid=<201502121433.t1CEWprk008797@localhost.localdomain>, proto=SMTP, daemon=MTA, relay=server114 [127.0.0.1] Feb 12 23:34:16 server114 sendmail[8797]: t1CEWprk008797: to=****@gmail.com, delay=00:00:26, mailer=esmtp, pri=30010, dsn=4.4.3, stat=queued |
'linux' 카테고리의 다른 글
[서버구축] FTP (0) | 2016.03.08 |
---|---|
[서버구축] DNS (0) | 2016.03.08 |
Shell Script (0) | 2016.03.08 |
Visual Editor(vi editor) 명령어 / network 정보 (0) | 2016.03.08 |
[명령어] - 3. Process / RPM / Cron 관리 (0) | 2016.03.08 |