給未來的裕翔
預設sendmail只收localhost的信
telnet localhost 25
注意, 要把sendmail加入/etc/hosts.allow
否則在mail from:xxx@yyy就會access denied了
以telnet進入後(能進入就表示sendmail或postfix有開)
mail from:bob@yahoo.com.tw
(上面寄件者是假冒用, 可以隨便打, 別被目標mail server擋下即可)
(那個冒號前後要不要空格皆可)
rcpt to:yushiangfu@gmail.com
(上面收件者別亂打, 不然怎知有沒成功)
data
subject:test-test-test
test-content
.
quit
寄信完成!
預設是sendmail
如果要改postfix, 安裝好後
alternatives --config mta, 選postfix
chkconfig sendmail off
service sendmail stop
在alternatives裡面
*是預設, +是目前使用
postfix會用到的port不只一個
要擋的話, 針對port 25/tcp即可
/etc/mail裡面都是sendmail的東西
/etc/postfix裡面都是postfix的東西
因為/etc/mail/sendmail.cf語法太難懂
所以有了postfix, 設定檔在
/etc/postfix/main.cf
在main.cf裡面, 有幾個設定要設定
myhostname = stationX.example.com
mydomain = example.com
myorigin = $myhostname
對方收我信就是bob@stationX.example.com
如果是myorigin = $mydomain
對方收我信就是bob@example.com
如此一來, 對方回信不會直接到我電腦
MTA必須加設/etc/aliases讓收到的信自動轉給我
mydestination, 替誰收信, 預設即可
inet_interfaces = all (關鍵步驟)
原本的inet_interfaces = localhost
所以我必須也跟著telnet localhost 25
就算telnet自己public IP也不行, 現在改成all就可以了
mynetwork_style = host
上面設定是, 一堆把我(MTA)設定為smtp server的人
我只幫誰寄(relay)
還有一個設定預設不存在
smtp_hostlookup = native,dns
先看/etc/hosts再看DNS
只有postfix需要這樣設定, 因為sendmail預設會看/etc/hosts
最後最後
head_check和body_check可作可不作,過濾用
現在不作也可以後面的procmail補作
如果對方的MTA沒開導致我的信寄不出去
可以用postqueue -p查看寄不出去的信
萬一對方MTA打開了, 剛失敗的信預設一小時候才會再寄
想要馬上寄出的話, postqueue -f
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment