postfix mailserver

postfix
(http://www.postfix.org/)

相關指令
postconf 查閱postfix的相關設定
postalias 設定別名資料庫的指令,將aliases轉成aliases.db
 ps:用法為postalias hash:/etc/aliases
postmap 轉換access成access.db
 ps:用法為postmap hash:/etc/postfix/access
postcat 查看某個佇列的信件
 ps:佇列的檔案一般在/var/spool/postfix/底下
postqueue 列出寄信佇列內容
 -p 列出佇列內容,結果和mailq一樣
postfix
 check 檢查相關檔案或權限是否設定正確
 start 啟動postfix
 stop 停止postfix
 flush 將佇列中的信強制寄出
 reload 重讀main.cf設定檔

相關檔案
main.cf //主要的 postfix 設定檔,通常在/etc/postfix下
access  //設定主機使用權限,通常在/etc/postfix下
/etc/aliases  //設定郵件別名用的檔案
.forward  //this is a file in user home dictionary ,operator in permit is 600 . a line a useremail in the file .
when anybody send mail to the user ,mail server will auto send mail to what user in .forward

........................................................................

main.cf 
(1等號兩邊要空白,2若有多資料建議用'逗號+空白'來分隔,3若資料重覆以最後的為優先)

inet_interfaces = all   //監聽所有介面的封包
myhostname = web.hopto.org   //主機名稱,需使用fqdn
myorigin = $myhostname  //發信源主機,目前使用myhostname的內容,在本機寄信時未加Mail from就以此值為準
mydestination =  $myhostname   //主機收信時,信件的目標主機位置符合mydestination才會接收
mynetworks = 規定信任的用戶端才可將信交給mda做relay(寄信)的動作

smtpd_recipient_restrictions = option1, option2,... //進階relay設定,option有以下
  permit_mynetworks :在mynetworks這個項目設定的網域,IP都可被允許連線

maximal_queve_lifttime = 1d
queue_run_delay = 10m
always_bcc = usera    //所有的寄出信都備份到usera,usera可改成mail地址
smtpd_recipient_limit = 2 //一封信最多只能轉寄2次
message_size_limit = 1024 //限制信件大小為1k,需和mailbox_size_limit一起設定
mailbox_size_limit = 10240 //個人信箱的大小限制10k,需和message_size_limit一起設定

alias_map = hash:/etc/aliases //設定郵件別名
alias_database = hash:/etc/aliases //設定郵件別名

........................ 
限制寄件者
smtpd_sender_restrictions = < action>
常用action如下
reject_unknown_client 無法反解對方ip時拒絕
ps:
因無法反解對方ip而拒絕的log大致如下
Oct 29 11:26:32 mailser postfix/smtpd[8137]: NOQUEUE: reject: RCPT from unknown[202.144.223.49]: 450 4.7.1 Client host rejected: cannot find your hostname, [202.144.223.49]; from= to= proto=ESMTP helo=
reject_unknown_sender_domain 找不到dns裡的mx/a記錄時拒絕

ps:
unknown_address_reject_code = 530 //將上行的錯誤指令碼450改成530
unknown_client_reject_code = 540 //將上行的錯誤指令碼450改成540
ps:
若對方反解不到,但又要收對方信,可把對方ip加入mynetworks
1 將對方IP加入信任名單
mynetworks = 11.22.33.44,
2 允許信件名單ip,其他則使用reject_unknown_client的規則
smtpd_sender_restrictions =
permit_mynetworks
reject_unknown_client

..................
設定虛擬主機
1
設定main.cf
virual_alias_map = hash:/etc/postfix/virual  //virtual host use
2
設定virual檔案,格式如下
 usera@zzz.com usera.zzz
 usera@xxx.com usera.xxx
3
執行postmap virual產生virual.db

ps:virtual使用正規表示法
編輯main.cf如下
virtual_alias_maps = regexp:/etc/postfix/virtual
正規表示法virtual範例如下
ex:
/^([8-9][0-9][0-9]{6,6})@/ ${1}@com1.tw, ${1}@com2.tw  #若帳號為89999999~99999999則寄到com1.tw和com2.tw
/^(.+)@net.tw$/ ${1}@com3.tw #若沒比對到的帳號,而且是@net.tw,則寄到com3.tw
/^(.+)@/ ${1}@com.tw #若沒比對到的帳號,則寄到com.tw

 

................

aliases 

設定郵件別名,就是收到信後自動在寄到某人的信箱
1
在/etc/aliases設定,規則如下
vituralname:realname1,realname2  //if anybody sends mail to vituralname ,realname1 and realname2 will receive the mail
realname1:realname1,realname2 //if anybody sends mail to realname1,realname1 and realname2 will receive the mail
name1:user@otherhostname 將寄給name1的寄到user@otherhostname
2
此檔被修改則需執行newaliases或postalias
postalias hash:/etc/aliases
ps,設定郵件別名時,在main.cf需要有
alias_map = hash:/etc/aliases
alias_database = hash:/etc/aliases

..............

access 

設定主機開放Relay或拒絕連線的來源或目標位址等資訊
1
編輯/etc/postfix/access,規則如下
ip或網域 ACCEPT或REJECT
ex:
拒絕動態IP所發出來的信件
dynamic.apol.com.tw REJECT We can't allow dynamic IP to relay!
dynamic.giga.net.tw REJECT We can't allow dynamic IP to relay!
dynamic.hinet.net REJECT We can't allow dynamic IP to relay!

2
修改後執行postmap hash:/etc/postfix/access
ps:在main.cf的mynetworks選項需要有hash:/etc/postfix/access

 

..................................................................................................

postfix的mail queues目錄
incoming 寄送到本地的信
active 正準備要送的信
defered 暫時無法被傳送的信,mail server會依Backoff time規則去試著在送一次
corrupt 無法讀取或毀損的信
hold 被暫停發送的信,需要手動才可寄出
defer 暫時無法被傳送的信,並記錄為何被延遲寄信,常發生在mail server被列入graylist的時候
bounce 每位收件者的傳送狀態,並記錄為何會被退信
ps:
該目錄通常在/var/spool/postfix

 

...... 

refer
http://www.l-penguin.idv.tw/article/postfix_spam.htm

AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDetect languageDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddishAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddish
偵測語言 » Afrikaans

AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDetect languageDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddishAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddish
偵測語言 » Afrikaans

AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDetect languageDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddishAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddish
偵測語言 » Afrikaans

AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDetect languageDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddishAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBulgarianCatalanChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutchEnglishEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekHaitian CreoleHebrewHindiHungarianIcelandicIndonesianIrishItalianJapaneseKoreanLatinLatvianLithuanianMacedonianMalayMalteseNorwegianPersianPolishPortugueseRomanianRussianSerbianSlovakSlovenianSpanishSwahiliSwedishThaiTurkishUkrainianUrduVietnameseWelshYiddish
偵測語言 » Afrikaans

2008-08-01 10:29:18發表 2013-10-31 00:04:35修改   

數據分析
程式開發
計算機組織與結構
資料結構與演算法
Database and MySql
manage tool
windows
unix-like
linux service

network
network layer3
network layer2
network WAN
network service
作業系統
數位鑑識
資訊安全解決方案
資訊安全威脅
Cisco security
Cisco network
Cisco layer3
Cisco layer2



  登入      [牛的大腦] | [單字我朋友] Powered by systw.net