### Sendmail 시작하기 ###


### AWS EC2 에서 Sendmail 을 사용하기 위한 설정


1. aws support case 를 통해서 ec2 에 대한 25 port 사용허가를 요청한후 허가를 받는다. 


https://aws.amazon.com/premiumsupport/knowledge-center/ec2-port-25-throttle/

https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request


위의 요청은 root account 를 통해서만 가능하다. 



2. yum install -y sendmail sendmail-cf 명령을 통해 sendmail 을 설치한다. 


2017년 8월 28일 까지의 최신 버전에는 sendmail 를 기본 설치 및 서비스가 올라와 있으며, sendmail-cf 만 추가 설치 진행하면 된다. 


 - RHEL, Amazon Linux 

yum install -y sendmail sendmail-cf


 - Ubuntu

apt-get install sendmail


 - Suse

zypper install sendmail



3. iptable 허용 여부 및 selinux 여부를 확인


iptable 은 기본정책이 되어 있는것은 없으며, selinux 도 disable 로 되어 있습니다. 


iptables -L -> 정책 확인 명령어

iptables -F -> 전체 정책 삭제 명령어


getenforce -> selinux 상태 확인 명령어

setenforce 0 -> selinux 가 Enforcing 일때 


Amazon Linux, Redhat Linux 는 Selinux 설치되어 있으며, 초기는 Disabled 상태 / Ubuntu Linux, Suse Linux 는 Selinux 설치 안되어 있습니다.

Amazon, Redhat, Ubuntu, Suse 전부 iptables 정책은 걸려 있지 않습니다.



4. 서비스할 도메인의 등록 (local-host-names)


local-host-names 을 편집합니다. 


vim /etc/mail/local-host-names 


# local-host-names - include all aliases for your machine here.


smtp01.test.com

smtp02.test.com



5. 메일서버를 외부에서 사용할수 있도록 sendmail.mc 파일 수정


vi /etc/mail/sendmail.mc


dnl ### allow mail DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl


# 디비 등록

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf


6. sendmail.cf 도메인 등록


vi /etc/mail/sendmail.cf


# my official domain name

# ... define this only if sendmail cannot automatically determine your domain

Djtest.com




7. 테스트를 위한 mail 명령어 설치


 - RHEL, Amazon Linux

yum install -y mailx


 - Ubuntu

apt install mailutils


 - Suse

zypper install mailx


8. local mail 발송 테스트


ip-xxx-xxx-xxx-xxx:~ # mail localhost root

Subject: test

123

456

7678

.

EOT




9. 메일 수신 확인


From ec2-user@ip-10-90-10-249  Thu Sep  7 01:23:14 2017

Return-Path: <ec2-user@ip-10-90-10-249>

Received: from ip-10-90-10-249 (localhost [127.0.0.1])

        by ip-10-90-10-249 (8.14.9/8.14.9/SuSE Linux 0.8) with ESMTP id v871NE4w001567;

        Thu, 7 Sep 2017 01:23:14 GMT

Received: (from root@localhost)

        by ip-10-90-10-249 (8.14.9/8.14.9/Submit) id v871NE5f001566;

        Thu, 7 Sep 2017 01:23:14 GMT

From: cloud-init created default user <ec2-user@ip-10-90-10-249>

Message-Id: <201709070123.v871NE5f001566@ip-10-90-10-249>

Date: Thu, 07 Sep 2017 01:23:13 +0000

To: root@ip-10-90-10-249, localhost@ip-10-90-10-249

Subject: test

User-Agent: Heirloom mailx 12.5 7/5/10

MIME-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit



123

456

7678






 - Amazon Linux Sendmail version 


[root@ip-10-90-10-49 ~]# rpm -qa | grep sendmail

sendmail-8.14.4-9.14.amzn1.x86_64

sendmail-cf-8.14.4-9.14.amzn1.x86_64


 - Redhat Linux Sendmail version 

[root@ip-10-90-10-54 ~]# rpm -qa | grep sendmail

sendmail-cf-8.14.7-5.el7.noarch

sendmail-8.14.7-5.el7.x86_64


 - Suse Linux Sendmail version

ip-10-90-10-249:/etc/mail # rpm -qa | grep sendmail

sendmail-8.14.9-2.80.x86_64


 - Ubuntu Linux Sendmail version

ubuntu@ip-10-90-10-130:~$ dpkg -l | grep sendmail

ii  sendmail                         8.15.2-3                                   all          powerful, efficient, and scalable Mail Transport Agent (metapackage)

ii  sendmail-base                    8.15.2-3                                   all          powerful, efficient, and scalable Mail Transport Agent (arch independent files)

ii  sendmail-bin                     8.15.2-3                                   amd64        powerful, efficient, and scalable Mail Transport Agent

ii  sendmail-cf                      8.15.2-3                                   all          powerful, efficient, and scalable Mail Transport Agent (config macros)

ubuntu@ip-10-90-10-130:~$












### Sendmail 정리 ### [amazon linux]


### SES 문서에 언급되어 있는 Sendmail 관련 내용

http://docs.aws.amazon.com/ko_kr/ses/latest/DeveloperGuide/sendmail.html



### Sendmail 을 사용하기 위해서 "yum install sendmail" 을 통해 Sendmail 을 설치


[root@ip-10-90-10-49 ~]# yum install sendmail

Loaded plugins: priorities, update-motd, upgrade-helper

amzn-main                                                                                     | 2.1 kB  00:00:00

amzn-updates                                                                                  | 2.3 kB  00:00:00

Package sendmail-8.14.4-9.14.amzn1.x86_64 already installed and latest version

Nothing to do

[root@ip-10-90-10-49 ~]#



### Sendmail 설정을 위한 Package 설치 "yum install sendmail-cf"


[root@ip-10-90-10-49 ~]# yum install sendmail-cf

Loaded plugins: priorities, update-motd, upgrade-helper

Resolving Dependencies

--> Running transaction check

---> Package sendmail-cf.x86_64 0:8.14.4-9.14.amzn1 will be installed

--> Processing Dependency: m4 for package: sendmail-cf-8.14.4-9.14.amzn1.x86_64

--> Running transaction check

---> Package m4.x86_64 0:1.4.16-9.10.amzn1 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


=====================================================================================================================

 Package                    Arch                  Version                             Repository                Size

=====================================================================================================================

Installing:

 sendmail-cf                x86_64                8.14.4-9.14.amzn1                   amzn-main                316 k

Installing for dependencies:

 m4                         x86_64                1.4.16-9.10.amzn1                   amzn-main                263 k


Transaction Summary

=====================================================================================================================

Install  1 Package (+1 Dependent package)


Total download size: 579 k

Installed size: 1.4 M

Is this ok [y/d/N]: y

Downloading packages:

(1/2): m4-1.4.16-9.10.amzn1.x86_64.rpm                                                        | 263 kB  00:00:00

(2/2): sendmail-cf-8.14.4-9.14.amzn1.x86_64.rpm                                               | 316 kB  00:00:00

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

Total                                                                                733 kB/s | 579 kB  00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : m4-1.4.16-9.10.amzn1.x86_64                                                                       1/2

  Installing : sendmail-cf-8.14.4-9.14.amzn1.x86_64                                                              2/2

  Verifying  : sendmail-cf-8.14.4-9.14.amzn1.x86_64                                                              1/2

  Verifying  : m4-1.4.16-9.10.amzn1.x86_64                                                                       2/2


Installed:

  sendmail-cf.x86_64 0:8.14.4-9.14.amzn1


Dependency Installed:

  m4.x86_64 0:1.4.16-9.10.amzn1


Complete!

[root@ip-10-90-10-49 ~]#



'MAIL > Sendmail' 카테고리의 다른 글

Sendmail 설정파일  (0) 2017.10.31

+ Recent posts