글 수 16
postfix를 설치한 목적은 회원가입 인증메일, 아이디/비밀번호찾기 메일을 발송하기 위함입니다(php를 통한 발송) 따라서 이글에서는 유저별로 메일디렉토리를 구성해서 따로 저장,발송 한다던지 접근제어 하는법을 다루지 않습니다.
apt-get update
apt-get install postfix
2. edit config file
vi /etc/postfix/main.cf
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
2. edit config file
vi /etc/postfix/main.cf
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
relay_domains = $mydestination
smtpd_client_restrictions = permit_mynetworks,permit
smtpd_client_restrictions = permit_mynetworks,permit
없는 라인은 맨 아랫줄에 만들어준다.
3. Start
/etc/init.d/postfix restart (or reload)
4. Test
텔넷 클라이언트 (putty같은) 혹은 터미널에서 아래 커맨드를 입력합니다.
yourdomain.com 이라고 되있는 부분은 본인의 도메인을 뜻합니다.
파란색으로 색칠된 부분이 입력한 커맨드입니다.
root@localhost:# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.yourdomain.com ESMTP Postfix (Ubuntu)
mail from:admin@yourdomain.com
250 2.1.0 Ok
rcpt to:admin@naver.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
From:admin@yourdomain.com
To:admin@naver.com
Subject: hello, this is test mail
Hello, this is test mail
i love gnu and linux
testing is funny
.
250 2.0.0 Ok: queued as DBAA71B8594
quit
221 2.0.0 Bye
Connection closed by foreign host.
이제 수신이 된 것을 확인하시면 됩니다.
4. php로 메일 발송
/etc/php.ini (php 설정파일)를 에디터 편집기로 연후 아래와 같이 수정합니다.[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = mail@yourdomain.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "sendmail -t -i -F mail@yourdomain.com -f mail@yourdomain.com"
php mail함수를 통해 메일을 발송해보면 잘되는것을 확인하실수 있습니다.