Postfixを導入しよう

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にUNIXUSER 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次


Part II Posifix

Postfix

Postfixsendmail
sendmail
alias
alias ~/.forward 
sendmail
sendmail 

sendmail
sendmail
 main.cf []
sendmail.cf 
sendmailCF


--[]----------------------------------------------------

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

sendmail()





 sendmail 
RELEASE_NOTEPostfix


()------------------------------------------------------------
http://www.muine.org/postfix/big-picture.html 
------------------------------------------------------------------

Postfix

sendmail

sendmail

  
  
  Postfixsendmail
  
  
  
  

  sendmail
   mbox 
   () /var/mail/ 
  OS
  () sticky bit 
  (root)

  --()------------------------------------------------
  funduro{yuuji}% ls -lFd /var/mail
  drwxrwxrwt  2 root  wheel  512 Jun 30  2000 /var/mail/
  ------------------------------------------------------------

   mbox 
  
  
  ([])Postfix 
  
   Venema 

	No Postfix program is set-uid. Introducing the concept was the
	biggest mistake made in UNIX history. Set-uid (and its weaker
	cousin, set-gid) causes more trouble than it is worth.

  mbox
   setgid root
  
  mbox /var/mail/ 
  

  --[]----------------------------------------------------
  http://www.postfix.org/security.html 
  http://cr.yp.to/maildisasters/postfix.19981221 
  
  ------------------------------------------------------------

  mbox

  mbox 
   "From " 
   
  "From " "From "
  
  MTAmboxpoppermbox
  MUA/
  mbox
  
  
  
  

  mbox
  
  mbox
  

  NFS
  POPNFSmbox
  mbox
  MUANFS
  
  NFS
  NFS
  
   Maildir 


  Maildir

  Maildir qmail  D.J.Bernstein qmail
  Maildir
  
  
  NFS
  

  MaildirPostfix
  Maildir
  

  Postfix

  sendmail
  mboxsendmail 
  MTA
  POPIMAPMaildir
  POP/IMAP
  
  Maildir
  Part4MaildirPOP/IMAP
  

  Postfix

  * 
  * 
  * sendmailPostfix

  

    

    PC-UNIX
    NetBSD  Vine Linux OSPostfix 
    OS
    
    
    
     snapshot-20010201 
    ftp://ring.aist.go.jp/pub/net/mail/postfix/index.html 
    CD-ROM snapshot-20010201.tar.gz 
    
    Perl
    
    PCRE(Perl-Compatible Regular
    Expression) 
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xxx.tar.gz 
     pcre-3.4.tar.gz CD-ROM 
    

    Postfix UID  GID 
    Postfix UIDMaildrop 
    GID()
    `postfix'  
    `postfix' passwdOS
     `postfix',
    `maildrop' `postfix'  NetBSD,
    Linux, Solaris2 

    # groupadd postfix
    # groupadd maildrop
    # useradd -s /etc/nologin -d /var/spool/postfix -g postfix \
	-c 'Postfix pseudo-user' postfix

    useradd
    

    # vi /etc/group	(GID)
        
	maildrop:*:11:
	postfix:*:12:

    # vipw		(UID
			 GIDpostfix)

     postfix:*:12:12::0:0:Postfix pseudo-user:/var/spool/postfix:/sbin/nologin


    UID/GIDPostfix
     PCRE 

    # tar zxpf snapshot-20010201.tar.gz
    # cd snapshot-20010201
    # tar zxpf ../pcre-3.4.tar.gz

    PCREPostfixPCRE
    make()
    

    # cd pcre-3.4
    # ./configure && make
    # cd ..

    PostfixPCREmake

    # make -f Makefile.init makefiles \
	   CCARGS='-DHAS_PCRE -I../../pcre-3.4' \
	   AUXLIBS=../../pcre-3.4/.libs/libpcre.a
    # make

    PCRE
    
    PCREPostfix
    

    # make -f Makefile.init makefiles
    # make

    Postfix
    OSsendmail, mailq, newaliases
    
    OS
    PostfixsendmailOSsendmail
    
     Postfix  /usr/local/postfix 
    

    # make install

    make install 
     [ ] 
     [ ] 

    * install_root: [/]

      
      Postfix chroot chroot
       / 
       install_root 
      
       / ()

    * tempdir: [/usr/home/yuuji/make/postfix/snapshot-20010201]

      

    * config_directory: [/etc/postfix]

      
      /etc/postfix 

    * daemon_directory: [/usr/libexec/postfix] /usr/local/postfix
                                               ~~~~~~~~~~~~~~~~~~
      Postfix
       /usr/local/postfix 

    * command_directory: [/usr/sbin] /usr/local/postfix
                                     ~~~~~~~~~~~~~~~~~~
      Postfix
      /usr/local/postfix 

    * queue_directory: [/var/spool/postfix] 

      
      

    * sendmail_path: [/usr/sbin/sendmail] /usr/local/postfix/sendmail
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Postfix  sendmail 
       sendmail 
       /usr/local/postfix 
       sendmail 
      

    * newaliases_path: [/usr/bin/newaliases] /usr/local/postfix/newaliases
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      sendmail_path newaliases
       /usr/local/postfix 

    * mailq_path: [/usr/bin/mailq] /usr/local/postfix/mailq
                                   ~~~~~~~~~~~~~~~~~~~~~~~~
      mailq
      /usr/local/postfix 

    * mail_owner: [postfix] 

      
       postfix 
      

    * setgid: [no] maildrop

      
      GID
      GID maildrop 
      

    * manpages: [/usr/local/man]

      
      

    
    


    

    MTA
     Postfix  sendmail 
     main.cf (
    )
    

    
    
    
    
    
    
    
    
    20001011
    

     Postfix  
    /etc/postfix 
    ( )

--  : /etc/postfix  ---------------------
ballius{yuuji}% ls                                          [/etc/postfix]
LICENSE                 regexp_table            sample-rate.cf
access                  relocated               sample-regexp.cf
aliases                 sample-aliases.cf       sample-relocated.cf
canonical               sample-auth.cf          sample-resource.cf
install.cf*             sample-canonical.cf     sample-rewrite.cf
main.cf                 sample-debug.cf         sample-smtp.cf
main.cf.default         sample-filter.cf        sample-smtpd.cf
master.cf               sample-flush.cf         sample-transport.cf
pcre_table              sample-ldap.cf          sample-virtual.cf
postfix-script*         sample-lmtp.cf          transport
postfix-script-diff     sample-local.cf         virtual
postfix-script-nosgid*  sample-misc.cf
postfix-script-sgid*    sample-pcre.cf
------------------------------------------------------------------------------

     main.cf 
    
     Postfix 

    Postfix 

	 =  [, 2 [, 3  ]]

    
    ()
    
    
     $ ( ${}) 

    MTA

    * ()
    * 
    * SMTP(IP)

    

    *  = mail.foo.ymzk.org
    *  = foo.ymzk.org
    * (LAN)() = 10.0.250.0/24

     main.cf 
    

    # cd /etc/postfix
    # vi main.cf

     myorigin 
    
    

	myorigin = foo.ymzk.org

    ()

---[]---------------------------------------------------------------------
  myorigin = $mydomain 
 FQDN myorigin 
 
------------------------------------------------------------------------------

    
    mydestination ()myorigin
    localhost

	mydestination = $myhostname, localhost.$mydomain, $mydomain

    SMTP$mydestination 
    ()
    mynetworks 

	mynetworks = 10.0.250.0/24, 127.0.0.0/8

    
    
     Postfix 


    sendmail

    sendmailPostfix
    sendmailsendmail

	# kill `sendmailpid'

    sendmail
    

	# sendmail -q
	# sendmail -bp

    
    sendmail sendmail
    

	* sendmail	
	* mailq		
	* newaliases	/etc/aliasesdbm

     /usr/local/postfix/ 
    

	# cd /usr/sbin			(Solaris/usr/lib)
	# mv sendmail sendmail.ORIG
	# chmod 0 sendmail.ORIG
	# ln -s /usr/local/postfix/sendmail
	# cd /usr/bin
	# mv mailq mailq.ORIG
	# chmod 0 mailq.ORIG
	# ln -s /usr/local/postfix/mailq
	# mv newaliases newaliases.ORIG
	# chmod 0 newaliases.ORIG
	# ln -s /usr/local/postfix/newaliases

    mailwrapper()
     mailer.conf 
    
    /etc/mailer.conf(OpenBSD, NetBSD)
    /etc/mail/mailer.conf(FreeBSD) 

	sendmail	/usr/local/postfix/sendmail
	send-mail	/usr/local/postfix/sendmail
	mailq		/usr/local/postfix/sendmail
	newaliases	/usr/local/postfix/sendmail

--[ mailwrapper]------------------------------------------------------

 MTAsendmail
 sendmailMTA
 
 MUAsendmail
 MTA
 sendmail
 OS
 

 mailwrapperPerry
 E. Metzger sendmail
  mailer.conf 
 
 *BSD mailer.conf OS
  manpage 
----------------------------------------------------------------------------

    Postfixsendmail(argv[0])
     mailer.conf 
    sendmail

    Postfix 

    Postfix
     postfix  postfix 
    

	# postfix
	postfix-script: fatal: usage: postfix start (or stop, reload, abort, flush, or check)

    postfix

	* check		Postfix
			
			
	* start		Postfix
			check
	* stop		PostfixPostfix
			 stop/start 
			 reload 
	* abort		Postfix
	* flush		
	* reload	

    
    Postfix 

	# /usr/local/postfix/postfix start

    
     `testuser' 

	# tail -f /var/log/maillog &		()
	# echo 'This is test.' | Mail -s test testuser

    /var/mail/testuser 
    
     Mail 
    sendmail
    
    

    SMTP Open
    Relay Web
    
    http://www.kyoto.wide.ad.jp/mta/relaycheck.html 
    SMTP
    telnet 
    
    
    

	(ext)% telnet mail.foo.ymzk.org smtp
	                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Trying to 10.0.250.25...
	Connected to mail.foo.ymzk.org.
	Escape character is '^]'
	220 mail.foo.ymzk.org ESMTP Postfix
	helo ext.example.com    (helo)
	~~~~~~~~~~~~~~~~~~~~
	250 mail.foo.ymzk.org
	mail from: 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	250 Ok
	rcpt to: 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~
	554 : Recipient address rejected: Relay access denied

    "Relay access denied" 
     Open Relay  denied 
    

	250 Ok

     Open Relay 
    (main.cf) mydestination, mynetworks 
    Postfix
    
    
    

	# /usr/local/postfix/postconf | less

    postconf 

    

    
    Postfix
    (/etc/rc*) sendmail 
    "/usr/local/postfix/postfix start" 

  Postfix

  
  sendmail
  Postfix
  

    Maildir

    
    /var/mail/USER  mbox 
    
    Maildir

    PostfixMaildir 
     main.cf 

	home_mailbox = Maildir/

    
    Maildir 
    (/) ~/Maildir/ 
    Maildir

    main.cfPostfix

	# /usr/local/postfix/postfix reload

     Maildir/ 
     .forward 
    

	# tail -f /var/log/maillog &		()
	# echo 'This is test.' | Mail -s test testuser

     maillog  maildir 
    

    Feb  2 22:32:03 mail postfix/qmgr[13813]: E0542B1:
    from=, size=329, nrcpt=1 (queue active)
    Feb  2 22:32:04 mail postfix/local[14058]: E0542B1:
    to=, relay=local, delay=1, status=sent (maildir)

     ~testuser/Maildir/new/ 
    

    # ls -lF ~testuser/Maildir/new/
    -rw------- 1 testuser 391 Feb 2 23:40 981124816.14117_0.mail.foo.ymzk.org


    
    Maildir 
    

    MUA
    UnixMaildir
    MUAUnixMUA 
    MewWanderlust[] Maildir 
    Unix
    Mail
    MH[]
    MUA 
    
     /var/mail/USER (mbox)
     ~/.forward 
    mbox

---[]---------------------------------------------------------------------
 Mew: http://www.mew.org/
 Wanderlust: http://www.gohome.org/wl/
---[]---------------------------------------------------------------------
 
 
------------------------------------------------------------------------------

    UBE

    UBE(Unsolicited
    Bulk E-mail; SPAM)UBE
    

	* MAPS RBL Open Relay SMTP 
          
	* DNS()
          
	* 

    Postfix
    UBE
    
    
    
    
    
    
    
    UBE

    UBE
    UBE Open Relay  SMTP 
     Open Relay SMTP
    UBE
    SMTP
    UBE

    RBLsendmail
    Open Relay SMTP
    ()
    
    PC
    
    
    SMTP
    
    
    

    
    
    
    
    UBESMTP
    
    
    
    
    
    UBE
    
    ()
    
    
    
    
    
    
    
    

    UBE
    /
    UBE
    

	1. (Open Relay )
	2. 
	3. UBE
	4. UBE

    13UBE
    12

	1  
	2  MUA

    3
    ()
    [] UBE
    
    

---[]---------------------------------------------------------------------
 UBE
 From
 
 
 
 (
 )
 
------------------------------------------------------------------------------

    4
    ()Postfix
    

    1. 

    smtpd_client_restrictions 
    Postfix MAPS RBL 
    

	smtpd_client_restrictions = hash:/etc/postfix/badclient,
				    reject_maps_rbl

    hash:/etc/postfix/badclient 
    hash
     /etc/postfix/badclient 

		

    

	evil.example.com	REJECT
	kusemono.example.net	REJECT
	192.168.99.99		REJECT
	tomodachi.example.org	OK

    (REJECT)
    (OK)badclient 

	# /usr/local/postfix/postmap hash:/etc/postfix/badclient

    hash
    Postfix access(5) 

    reject_maps_rbl 
    
    maps_rbl_domains 

	maps_rbl_domains = rbl.maps.vix.com

     rbl.maps.vix.com 
    


    2,3. 

    smtpd_sender_restrictions 

	smtpd_sender_restrictions = reject_unknown_sender_domain,
				    hash:/etc/postfix/access

    reject_unknown_sender_domain
    
    hash:/etc/postfix/access 
    /etc/postfix/access  badclient 
    &

	# /usr/local/postfix/postmap hash:/etc/postfix/access

    smtpd_sender_restrictions 
    /etc/postfix/sample-smtpd.cf 
    


    4. 

    
    header_checks 
     hash: 
    

	header_checks = regexp:/etc/postfix/header_check

     /etc/postfix/header_check 
    

		

    hash
    Subject "money" 
    

	/^Subject: .*money.*/		REJECT

     moneyless REJECT
    PCRE
    PCRE

	header_checks = pcre:/etc/postfix/header_check

    Perl"money" 
    

	/^Subject: .*\.*/		REJECT

    Perl
    
    
    
    
    

    

     postfix reload 
    


  

  
  

	* 
	* 

  
   main.cf mydestination 
  

	mydestination = $myhostname, localhost.$mydomain

  
   relayhost 
  

	relayhost = mail.foo.ymzk.org

  
  

  

  
  sendmail
  

  Postfix  Vine Linux MTA
  
  sendmailPostfix 
  sendmail
  
  sendmail
  sendmail
  
  Postfix
  


yuuji@gentei.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]