發 EDM 的 Email Server
採用 Ubuntu + Postfix 來處理
由於網域 xxx.com.tw 是讓 Godaddy 來管理 , 所以要先去 Godadday
新增一筆 MX
; For further information, please consult the BIND documentation
; located on the following website:
;
; http://www.isc.org/
;
; And RFC 1035:
;
; http://www.ietf.org/rfc/rfc1035.txt
;
; Please note that we do NOT offer technical support for any use
; of this zone data, the BIND name server, or any other third-
; party DNS software.
;
; Use at your own risk.
; SOA Record
xxx.com.tw. 600 IN SOA ns15.domaincontrol.com. dns.jomax.net (
2016030802
28800
7200
604800
600
)
; A Records
s1 600 IN A x.x.x.x
s2 600 IN A x.x.x.x
@ 600 IN A x.x.x.x
; CNAME Records
ftp 3600 IN CNAME @
www 3600 IN CNAME @
email 3600 IN CNAME @
; MX Records
@ 3600 IN MX 10 email.xxx.com.tw
; NS Records
@ 3600 IN NS ns16.domaincontrol.com
@ 3600 IN NS ns15.domaincontrol.com
# apt-get install postfix
# vim /etc/postfix/main.cf
myhostname = ip-172-31-30-43
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = email.xxx.com.tw, xxx.com.tw , localhost # 遇到任事的可以收
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.xx.xx.xx/20 # 准許本機 跟 172的網段可以寄信 , 後續也可以透過 iptables 或 Ec2 的 Security Group 來做
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/ # 採用一封信件一個檔案
驗證
# telnet xxx.com.tw 25
Trying 52.x.x.0...
telnet: connect to address 52.xx.xx.0: Connection timed out
要去打開 Ec2 的 Security Group 25 Port
Again
# telnet xxx.com.tw 25
Trying 52.xxx.xxx.0...
Connected to xxx.com.tw.
Escape character is '^]'.
220 ip-172-31-30-43 ESMTP Postfix (Ubuntu)
ehlo localhost
250-ip-172-31-30-43
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
或安裝 mail client tools
# apt-get install mailutils
echo "Message Body" | mail -s "2Message Subject" fifi@xxx.com.tw
透過外部信件 ex. Gmail 寄給 fifi@xxx.com.tw
確認可以收 跟 送信
PS ( 如果寄到 gmail or Yahoo or other mail Server , 有時候要注意反解析網域寄信
不然會檔 , 自己用nslookup 來檢查 或 去跟 ISP 申請 )
收到信件的話會再帳號的 home下多一個 Maildir的目錄
裡面會有寄過來的信件 list
/home/xxx/Maildir
Maildir/
├── cur
├── new
│ ├── 1457580107.Vca01I6193bM206156.ip-172xxxx0-43
│ ├── 1457590218.Vca01I6194eM276640.ip-172xxxxs-43
│ └── 1457591864.Vca01I6194cM347714.ip-172xxxx-43
└── tmp
或看 mail log
# tail -f /var/log/mail.log
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtpd[4088]: disconnect from mail-pf0-f174.google.com[209.85.192.174]
Mar 10 07:10:50 ip-172-31-30-43 postfix/smtp[4060]: F21726193B: to=<txxx@gmail.com>, orig_to=<xxx@xxx.com.tw>, relay=gmail-smtp-in.l.google.com[64.233.187.27]:25, delay=0.91, delays=0.01/0/0.35/0.55, dsn=2.0.0, status=sent (250 2.0.0 OK 1457593837 g24si4022733pfj.91 - gsmtp)
Mar 10 07:10:50 ip-172-31-30-43 postfix/qmgr[1515]: F21726193B: removed
@ Alias 新群組信件帳號 , 驗證
# vim /etc/aliases
# See man 5 aliases for format
postmaster: root
cs: xxx1@gmail.com,xxx2@gmail.com
# newaliases
echo "Message Body" | mail -s "2Message Subject" cs@xxx.com.tw
沒有留言:
張貼留言