Postfix 2.6.5 Install (rpm)


Postfix 2.6.5をVDAに対応させてビルドした時のメモ。

  • Vine Linux 5.0
  • Postfix 2.6.5
  • MySQL 5.1.41
  • Cyrus-SASL 2.1.23

まずはVine Seedからソースパッケージを落としてくる。

$ rpm -ivh postfix-2.6.5-2vl6.src.rpm

VDAパッチを落としてSOURCESフォルダに入れておく。

$ cd ~/rpm/SOURCES
$ wget http://vda.cvs.sourceforge.net/viewvc/*checkout*/vda/VDA/postfix-2.6.5-vda-ng.patch


VDAパッチが当たるようにspecファイルに追記する。

$ cd ~/rpm/SPECS
$ vi postfix.spec
#%define build_mysql %{?_with_mysql:1}%{!?_with_mysql:0}
#%define build_pgsql %{?_with_pgsql:1}%{!?_with_pgsql:0}

%define build_mysql 1
%define build_pgsql 1

%define _sysconfdir   /etc
%define _data_dir     %{_var}/lib/postfix

%define origversion 2.6.5

# japanese documant for 2.5.x is not ready.
# %define jconfversion 2.2.0
# %define jmanversion 2.2.9
# %define jhtmlversion 2.2.9
# %define jreadmeversion 2.2.9

Summary:   Postfix Mail Transport Agent
Summary(ja):   Postfix メールトランスポートエージェント
Name:      postfix
Version:   %{origversion}
Release:   2%{?_dist_release}
URL:       http://www.postfix.org/
License:   Distributable - IBM PUBLIC LICENSE VERSION 1.0 - SECURE MAILER
Group:     System Environment/Daemons

Source0:   ftp://postfix.cloud9.net/official/%{name}-%{version}.tar.gz
Source1:   postfix.aliases
Source2:   postfix.cron
Source3:   postfix.init

# japanese documents for 2.5.x is not ready.
# Source10:  http://www.kobitosan.net/postfix/archives/postfix_jconf-%{jconfversion}.tar.gz
# Source20:  http://www.kobitosan.net/postfix/archives/postfix_jman-%{jmanversion}.tar.gz
# Source30:  http://www.kobitosan.net/postfix/archives/postfix_jhtml-%{jhtmlversion}.tar.gz
# Source40:  http://www.kobitosan.net/postfix/archives/postfix_jreadme-%{jreadmeversion}.tar.gz

Patch0:    postfix-2.1.5-vine.patch
Patch1:    postfix-2.2.10-main.cf-lib64.patch
Patch2:    postfix-2.6.5-vda-ng.patch

# patches 100-199 are imported from debian package.
# patches 100/101 for postfix 2.5.x are from suse.  
Patch100: postfix-2.6.1-dynamicmaps.patch

# patches 200-299 are imported from rh/fedora
Patch200: postfix-2.5.7-large-fs.patch	   
Patch210: postfix-2.5.5-open_define-vine.patch

Provides:  smtpdaemon
Conflicts: sendmail
Requires(pre):    chkconfig
BuildRequires: db4-devel >= 4.6.21, pam-devel, gdbm-devel
BuildRequires: cyrus-sasl-devel >= 2
BuildRequires: openldap-devel, openssl-devel
BuildRequires: pcre-devel
%if %build_mysql
BuildRequires: MySQL-devel
%endif
%if %build_pgsql
BuildRequires: postgresql-devel
%endif

Requires:    cyrus-sasl >= 2, cyrus-sasl-md5, cyrus-sasl-plain 
Requires:    gdbm, pam, openssl
Requires(pre):      db4 >= 4.6.21
Obsoletes: postfix-beta
BuildRoot: %{_tmppath}/%{name}-%{version}-root

Vendor: Project Vine
Distribution: Vine Linux
Packager: Daisuke SUZUKI 


%description
Postfix aims to be an alternative to the widely-used sendmail
program.  Sendmail is responsible for 70 percent of all e-mail delivered
on the Internet.  With an estimated 100 million users, that's an
estimated 10 billion (10^10) messages daily. A stunning number.

Although IBM supported the Postfix development, it abstains from
control over its evolution. The goal is to have Postfix installed
on as many systems as possible. To this end, the software is given
away with no strings attached to it, so that it can evolve with
input from and under control by its users.

#'
%description -l ja
Postfix は現在広く使われている sendmail を置き換える目的で
開発されています。sendmail は約 70% の E-mail サーバで使用
されています。また、その使用者は 100万人にもおよび、およそ
一日 1 千万通ものメールを処理しています。

Postfix の開発は IBM によってサポートされており、全世界の
全てのシステムを postfix にすることを目標としています。

%if %build_pgsql
%package pgsql
Summary: PGSQL map support for Postfix
Group:     System Environment/Daemons
Requires(pre): postfix = %{version}-%{release}
Requires: postgresql-libs, postgresql
%description pgsql
This package contains shared lib module which support
PostgreSQL map on Postfix.
%description -l ja pgsql
このパッケージには、Postfix で PostgreSQL を使うのに必要な
ライブラリが納められています。
%endif

%if %build_mysql
%package mysql
Summary: MySQL map support for Postfix
Group:     System Environment/Daemons
Requires(pre): postfix = %{version}-%{release}
%description mysql
This package contains shared lib module which support
MySQL map on Postfix.
%description -l ja mysql
このパッケージには、Postfix で MySQL を使うのに必要な
ライブラリが納められています。
%endif

%package ldap
Summary: LDAP map support for Postfix
Group:     System Environment/Daemons
Requires(pre): postfix = %{version}-%{release}
Requires: openldap
%description ldap
This package contains shared lib module which support
OpenLDAP map on Postfix.
%description -l ja ldap
このパッケージには、Postfix で OpenLDAP を使うのに必要な
ライブラリが納められています。

%package pcre
Summary: PCRE map support for Postfix
Group:     System Environment/Daemons
Requires(pre): postfix = %{version}-%{release}
Requires: pcre
%description pcre
This package contains shared lib module which support
PCRE map on Postfix.
%description -l ja pcre
このパッケージには、Postfix で PCRE マップを使うのに必要な
ライブラリが納められています。

%prep
# japanese documant for 2.4.x is not ready.
# %setup -q -a 10 -a 20 -a 30 -a 40
%setup -q 

%patch0 -p1 -b .vine

%ifarch x86_64
%patch1 -p1 -b .lib64
%endif

%patch2 -p1 -b .vda-ng

%patch100 -p1 -b .dynamicmaps
perl -pi -e 's,/usr/lib/,/usr/lib64/,' conf/postfix-files
perl -pi -e 's,-lmysqlclient,-lmysqlclient -L%{_libdir}/mysql,' src/global/Makefile.in

%patch200 -p1 -b .large-fs
%patch210 -p1 -b .open_define


# patching src/global/Makefile to remove dependency
pushd src/global
%if %build_mysql
:
%else
sed -ie "s/ dict_mysql.so/ /" Makefile.in
%endif
%if %build_pgsql
:
%else
sed -ie "s/ dict_pgsql.so/ /" Makefile.in
%endif
popd

%build
make makefiles \
	CCARGS="-DMAX_DYNAMIC_MAPS \
	        -DUSE_SASL_AUTH -I/usr/include/sasl \
	        -DUSE_CYRUS_SASL \
		-DHAS_LDAP \
		-DHAS_SSL -I/usr/include/openssl \
	        -DHAS_PCRE -I/usr/include/pcre \
%if %build_mysql
	        -DHAS_MYSQL -I/usr/include/mysql  \
%endif
%if %build_pgsql
		-DHAS_PGSQL -I/usr/include/pgsql \
%endif
		-DUSE_TLS" \
	AUXLIBS="-lsasl2 -lssl -lcrypto" \
	OPT="$RPM_OPT_FLAGS" DEBUG=""
for libs in master global util dns tls xsasl milter
do
  ln -sf lib${libs}.a lib/libpostfix-${libs}.so.1
done

# make %{?_smp_mflags} DEBUG="" OPT="$RPM_OPT_FLAGS" \
#      LD_LIBRARY_PATH=$(pwd)/lib:${LD_LIBRARY_PATH}

# using _smp_mflags makes build error. why? (2008.10.11)
make DEBUG="" OPT="$RPM_OPT_FLAGS" \
     LD_LIBRARY_PATH=$(pwd)/lib:${LD_LIBRARY_PATH} CDBSO=""

%install
rm -rf $RPM_BUILD_ROOT
rm -f html/Makefile.in
rm -f README_FILES/*.*

install -d $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily
install -d $RPM_BUILD_ROOT%{_sysconfdir}/postfix
install -d $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
install -d $RPM_BUILD_ROOT%{_bindir}
install -d $RPM_BUILD_ROOT%{_libdir}/postfix
install -d $RPM_BUILD_ROOT%{_mandir}/man{1,5,8}
install -d $RPM_BUILD_ROOT%{_mandir}/ja/man{1,5,8}
install -d $RPM_BUILD_ROOT%{_sbindir}
install -d $RPM_BUILD_ROOT%{_var}/spool/postfix
install -d $RPM_BUILD_ROOT%{_var}/spool/postfix/{active,corrupt,deferred,incoming,pid,public}
install -d $RPM_BUILD_ROOT%{_var}/spool/postfix/{bounce,defer,flush,maildrop,private,saved}

install -m755 bin/* $RPM_BUILD_ROOT%{_sbindir}
install -m755 libexec/* $RPM_BUILD_ROOT%{_libdir}/postfix
install -m755 lib/dict_* $RPM_BUILD_ROOT%{_libdir}/postfix
install -m755 lib/lib*.so.1 $RPM_BUILD_ROOT%{_libdir}

touch conf/dynamicmaps.cf
for i in main.cf master.cf access aliases canonical header_checks \
         main.cf.default post-install postfix-files postfix-script \
	 relocated transport virtual dynamicmaps.cf
do
  install -m644 conf/$i $RPM_BUILD_ROOT%{_sysconfdir}/postfix
done
for i in post-install postfix-script
do
  install -m755 conf/$i $RPM_BUILD_ROOT%{_sysconfdir}/postfix
done

install -m644 man/man1/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
install -m644 man/man5/*.5 $RPM_BUILD_ROOT%{_mandir}/man5
install -m644 man/man8/*.8 $RPM_BUILD_ROOT%{_mandir}/man8

# japanese documant for 2.4.x is not ready.
# install jman
# for i in 1 5 8
# do
#   install -m644 man-%{jmanversion}/ja/man$i/*.$i $RPM_BUILD_ROOT%{_mandir}/ja/man$i
# done

# jconf, jhtml, jreadme
# cp -a conf-%{jconfversion} sample.ja
# cp -a jhtml-%{jhtmlversion} html.ja
# cp -a readme-%{jreadmeversion} README_FILES.ja

install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/postfix/aliases
install -m755 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/postfix
install -m755 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/postfix

ln -sf postfix/aliases $RPM_BUILD_ROOT%{_sysconfdir}/aliases
ln -sf postfix/aliases.db $RPM_BUILD_ROOT%{_sysconfdir}/aliases.db

( cd $RPM_BUILD_ROOT%{_bindir}
  ln -sf ../sbin/sendmail mailq
  ln -sf ../sbin/sendmail newaliases
)
( cd $RPM_BUILD_ROOT%{_libdir}
  ln -sf ../sbin/sendmail sendmail
)

for I in etc/postfix/{aliases,access,canonical,header_check,relocated,transport,virtual}
do
   touch $RPM_BUILD_ROOT/$I{,.db}
done

# data dir
install -d $RPM_BUILD_ROOT%{_data_dir}

%pre
if [ `grep postfix %{_sysconfdir}/passwd | wc -l` = 0 ]; then
   %{_sbindir}/useradd -M -r -d %{_var}/spool/postfix -s "" \
                     -c "postfix" postfix || :
fi
if [ `grep postfix %{_sysconfdir}/group | wc -l` = 0 ]; then
  %{_sbindir}/groupadd -r postfix
fi
if [ `grep postdrop %{_sysconfdir}/group | wc -l` = 0 ]; then
  %{_sbindir}/groupadd -r postdrop
fi
#if [ -f %{_var}/lock/subsys/postfix ]; then
#   %{_sysconfdir}/rc.d/init.d/postfix stop
#fi


%post
/sbin/ldconfig
if ! grep -q "^tcp[[:space:]]" /etc/postfix/dynamicmaps.cf; then
  echo "Adding tcp map entry to /etc/postfix/dynamicmaps.cf"
  echo "tcp	%{_libdir}/postfix/dict_tcp.so		dict_tcp_open" >> /etc/postfix/dynamicmaps.cf
fi
/sbin/chkconfig --add postfix
if [ ! -f %{_sysconfdir}/postfix/aliases.db ]; then
  touch %{_sysconfdir}/postfix/aliases.db
fi
%{_sbindir}/postalias %{_sysconfdir}/postfix/aliases ||:
if [ ! -e %{_libdir}/sendmail ]; then
	ln -sf %{_sbindir}/sendmail %{_libdir}/sendmail
fi
/sbin/chkconfig --del sendmail &> /dev/null ||:
%{_sbindir}/postfix check >/dev/null 2>&1 ||:
if [ -f %{_var}/lock/subsys/postfix ]; then
   %{_sysconfdir}/rc.d/init.d/postfix restart
fi


%preun
if [ $1 = 0 ]; then
   if [ -f %{_var}/lock/subsys/postfix -a -f %{_sysconfdir}/rc.d/init.d/postfix ]; then
      %{_sysconfdir}/rc.d/init.d/postfix stop
   fi
   /sbin/chkconfig --del postfix
fi


%postun
/sbin/ldconfig
if [ $1 = 0 ]; then
   if [ `grep postfix %{_sysconfdir}/passwd | wc -l` = 1 ]; then
      %{_sbindir}/userdel postfix
   fi
   if [ `grep postfix %{_sysconfdir}/group | wc -l` = 1 ]; then
      %{_sbindir}/groupdel postfix
   fi
   if [ `grep postdrop %{_sysconfdir}/group | wc -l` = 1 ]; then
      %{_sbindir}/groupdel postdrop
   fi
   if ! [ -f %{_var}/lock/subsys/postfix ]; then
        rm -rf %{_var}/lock/subsys/postfix
   fi
fi

%if %build_pgsql
%post pgsql
if ! grep -q "^pgsql[[:space:]]" /etc/postfix/dynamicmaps.cf; then
  echo "Adding pgsql map entry to /etc/postfix/dynamicmaps.cf"
  echo "pgsql	%{_libdir}/postfix/dict_pgsql.so		dict_pgsql_open" >> /etc/postfix/dynamicmaps.cf
fi

%preun pgsql
if [ $1 = 0 ]; then
  if grep -q "^pgsql[[:space:]]" /etc/postfix/dynamicmaps.cf; then
    cp -f /etc/postfix/dynamicmaps.cf /etc/postfix/dynamicmaps.cf.rpmsave
    grep -v "^pgsql[[:space:]]" /etc/postfix/dynamicmaps.cf.rpmsave > /etc/postfix/dynamicmaps.cf
  fi
fi
%endif

%if %build_mysql
%post mysql
if ! grep -q "^mysql[[:space:]]" /etc/postfix/dynamicmaps.cf; then
  echo "Adding mysql map entry to /etc/postfix/dynamicmaps.cf"
  echo "mysql	%{_libdir}/postfix/dict_mysql.so		dict_mysql_open" >> /etc/postfix/dynamicmaps.cf
fi

%preun mysql
if [ $1 = 0 ]; then
  if grep -q "^mysql[[:space:]]" /etc/postfix/dynamicmaps.cf; then
    cp -f /etc/postfix/dynamicmaps.cf /etc/postfix/dynamicmaps.cf.rpmsave
    grep -v "^mysql[[:space:]]" /etc/postfix/dynamicmaps.cf.rpmsave > /etc/postfix/dynamicmaps.cf
  fi
fi
%endif

%post ldap
if ! grep -q "^ldap[[:space:]]" /etc/postfix/dynamicmaps.cf; then
  echo "Adding ldap map entry to /etc/postfix/dynamicmaps.cf"
  echo "ldap	%{_libdir}/postfix/dict_ldap.so		dict_ldap_open" >> /etc/postfix/dynamicmaps.cf
fi

%preun ldap
if [ $1 = 0 ]; then
  if grep -q "^ldap[[:space:]]" /etc/postfix/dynamicmaps.cf; then
    cp -f /etc/postfix/dynamicmaps.cf /etc/postfix/dynamicmaps.cf.rpmsave
    grep -v "^ldap[[:space:]]" /etc/postfix/dynamicmaps.cf.rpmsave > /etc/postfix/dynamicmaps.cf
  fi
fi

%post pcre
if ! grep -q "^pcre[[:space:]]" /etc/postfix/dynamicmaps.cf; then
  echo "Adding pcre map entry to /etc/postfix/dynamicmaps.cf"
  echo "pcre	%{_libdir}/postfix/dict_pcre.so		dict_pcre_open" >> /etc/postfix/dynamicmaps.cf
fi

%preun pcre
if [ $1 = 0 ]; then
  if grep -q "^pcre[[:space:]]" /etc/postfix/dynamicmaps.cf; then
    cp -f /etc/postfix/dynamicmaps.cf /etc/postfix/dynamicmaps.cf.rpmsave
    grep -v "^pcre[[:space:]]" /etc/postfix/dynamicmaps.cf.rpmsave > /etc/postfix/dynamicmaps.cf
  fi
fi


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc COMPATIBILITY COPYRIGHT HISTORY LICENSE INSTALL PORTING RELEASE_NOTES
# japanese documant for 2.4.x is not ready.
# %doc conf.ja
# %doc html html.ja
# %doc README_FILES README_FILES.ja
%doc README_FILES
# %doc man-%{jmanversion}/readme_ja.txt
%{_sysconfdir}/aliases
%{_sysconfdir}/aliases.db
%config %{_sysconfdir}/cron.daily/postfix
%dir %{_sysconfdir}/postfix
%config %{_sysconfdir}/postfix/main.cf.default
%config %{_sysconfdir}/postfix/master.cf
%config(noreplace) %{_sysconfdir}/postfix/aliases
%config(noreplace) %{_sysconfdir}/postfix/access
%config(noreplace) %{_sysconfdir}/postfix/canonical
%config(noreplace) %{_sysconfdir}/postfix/header_check
%config(noreplace) %{_sysconfdir}/postfix/header_checks
%config(noreplace) %{_sysconfdir}/postfix/main.cf
%config(noreplace) %{_sysconfdir}/postfix/relocated
%config(noreplace) %{_sysconfdir}/postfix/transport
%config(noreplace) %{_sysconfdir}/postfix/virtual
%config(noreplace) %{_sysconfdir}/postfix/dynamicmaps.cf
%config %{_sysconfdir}/postfix/postfix-files
%config %{_sysconfdir}/postfix/post-install
%config %{_sysconfdir}/postfix/postfix-script
%config %{_sysconfdir}/rc.d/init.d/postfix
%{_bindir}/*
%dir %{_libdir}/postfix
%{_libdir}/postfix/*

%if %{build_pgsql}
%exclude %{_libdir}/postfix/dict_pgsql.so
%endif
%if %{build_mysql}
%exclude %{_libdir}/postfix/dict_mysql.so
%endif

%exclude %{_libdir}/postfix/dict_ldap.so
%exclude %{_libdir}/postfix/dict_pcre.so
%{_libdir}/lib*.so.1
%{_sbindir}/postalias
%{_sbindir}/postcat
%{_sbindir}/postconf
%attr(2755,root,postdrop) %{_sbindir}/postdrop
%{_sbindir}/postfix
%{_sbindir}/postkick
%{_sbindir}/postlock
%{_sbindir}/postlog
%{_sbindir}/postmap
%{_sbindir}/postmulti
%attr(2755,root,postdrop) %{_sbindir}/postqueue
%{_sbindir}/postsuper
%{_sbindir}/qmqp-sink
%{_sbindir}/qmqp-source
%{_sbindir}/sendmail
%{_sbindir}/smtp-sink
%{_sbindir}/smtp-source
%attr(-,root,man) %{_mandir}/man*/*
# %attr(-,root,man) %{_mandir}/ja/man*/*
%dir %{_var}/spool/postfix
%attr(0750,postfix,root) %dir %{_data_dir}
%attr(1733,postfix,postdrop) %dir %{_var}/spool/postfix/maildrop
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/active
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/corrupt
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/deferred
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/incoming
%attr(0755,root,root) %dir %{_var}/spool/postfix/pid
%attr(0710,postfix,postdrop) %dir %{_var}/spool/postfix/public
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/bounce
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/defer
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/flush
%attr(0710,postfix,postfix) %dir %{_var}/spool/postfix/private
%attr(0700,postfix,postfix) %dir %{_var}/spool/postfix/saved
%{_libdir}/sendmail

%if %build_pgsql
%files pgsql
%defattr(-,root,root)
%{_libdir}/postfix/dict_pgsql.so
%endif

%if %build_mysql
%files mysql
%defattr(-,root,root)
%{_libdir}/postfix/dict_mysql.so
%endif

%files ldap
%defattr(-,root,root)
%{_libdir}/postfix/dict_ldap.so

%files pcre
%defattr(-,root,root)
%{_libdir}/postfix/dict_pcre.so

%changelog
* Sat Feb 20 2010 Tomohiro "Tomo-p" KATO  2.6.5-2
- removed MySQL-shared from "Requires:" and "BuildRequires:".
- replaced "Prereq:" with "Requires(pre):".
- replaced "BuildPrereq:" with "BuildRequires:".

* Tue Feb 02 2010 Daisuke SUZUKI  2.6.5-1
- new upstream release
- rebuild with db4-4.8.0

* Sun Aug 16 2009 Daisuke SUZUKI  2.6.3-2
- change /var/spool/postfix/pid owner and permission
  (0700,postfix,postfix -> 0755,root,root)

* Mon Aug  3 2009 Satoshi IWAMOTO  2.6.3-1
- new upstream release

* Sat Jun  6 2009 Tomohiro "Tomo-p" KATO  2.6.2-1
- new upstream release.

* Sat May 30 2009 Tomohiro "Tomo-p" KATO  2.6.1-2
- added a missing file.

* Sat May 30 2009 Tomohiro "Tomo-p" KATO  2.6.1-1
- new upstream release.
- updated dynamicmaps patch.

* Fri May 22 2009 Tomohiro "Tomo-p" KATO  2.5.7-2
- made to build -mysql and -pgsql as default.
- rebuilt with MySQL-5.1.34.

* Wed May 13 2009 Satoshi IWAMOTO  2.5.7-1
- new upstream release
- update Patch200 from fc10

* Sun Mar 01 2009 NAKAMURA Kenta  2.5.6-2
- rebuilt with openldap-2.4.11

* Mon Jan 12 2009 Satoshi IWAMOTO  2.5.6-1
- new upstream release

* Sun Oct 12 2008 Satoshi IWAMOTO  2.5.5-4
- add patch200/patch210 from fedora

* Sun Oct 12 2008 Satoshi IWAMOTO  2.5.5-3
- add Requires cyrus-sasl-md5, cyrus-sasl-plain for smtp auth
- add Japanese description into sub packages

* Sat Oct 11 2008 Satoshi IWAMOTO  2.5.5-2
- update patch100/101 to fix libxsasl build issue
- remove smp flag in build section to solve build error
- add _data_dir

* Fri Oct 10 2008 Satoshi IWAMOTO  2.5.5-1
- new upstream release
- update patch100/101 to fit 2.5.5 (from suse)
- add %exclude dict_{my,pg}sql.so to %%files to avoid unneeded dependancy
  when option "--with XXsql" is specified. (from Vine 4.x update package)
- remove HAS_DLOPEN macro.

* Sat Sep 06 2008 Satoshi IWAMOTO  2.4.9-1
- new upstream release with security fix

* Sat Aug 30 2008 Satoshi IWAMOTO  2.4.8-2
- add %%if %%build_mysql and %%if %%mysql from BuildRequires section again
- remove unnessary dependency

* Thu Aug 28 2008 Satoshi IWAMOTO  2.4.8-1
- new upstream release with security fix

* Mon Aug 11 2008 Daisuke SUZUKI  2.4.7-4
- spec in UTF-8

* Fri Jun 20 2008 MATSUBAYASHI Kohji  - 2.4.7-3
- rebuilt against db4-4.6.21

* Tue Apr 15 2008 Tomohiro 'Tomo-p' KATO  2.4.7-2
- add HAS_DLOPEN macro.
- add USE_CYRUS_SASL macro.
- modify dynamicmaps.cf (/usr/lib -> %%{_libdir}).

* Thu Mar 25 2008 Satoshi IWAMOTO  2.4.7-1
- new upstream release
- update patch100 (it is based from mdk 2008.0)
- add smp_mflags in make section
- build under new versioning policy

* Thu Sep 20 2007 Ryoichi INAGAKI  2.2.10-0vl10
- rebuilt with postgresql-devel 8.2.5
- updated Source20, 30 and 40

* Fri May 18 2007 Daisuke SUZUKI  2.2.10-0vl9
- rebuild with new openssl

* Wed May 09 2007 MATSUBAYASHI Kohji  2.2.10-0vl8
- rebuilt with new toolchain and db4-4.3.x

* Fri Apr 13 2007 KANEKO Seiji  2.2.10-0vl7
-  fix typo in %%if statement for %%files mysql section.
- remove %%if %%build_mysql and %%if %%mysql from BuildRequires section,
  (Patch100 always builds dict_mysql.o and dict_pgsql.o)

* Fri Oct 27 2006 Daisuke SUZUKI  2.2.10-0vl6
- disable MySQL, PostgreSQL support by default.
  use "--with {mysql|pgsql}" to build them.

* Mon Sep 18 2006 NAKAMURA Kenta  2.2.10-0vl5
- add lib64 patch to correct daemon_directory on x86_64 architecture

* Wed Sep 13 2006 Daisuke SUZUKI  2.2.10-0vl4
- remove duplicated entry from aliases. ()

* Wed Sep 13 2006 Daisuke SUZUKI  2.2.10-0vl3
- add some pseudo accounts to aliases. ()
- add BuildPreReq: MySQL-shared

* Sun Aug 27 2006 NAKAMURA Kenta  2.2.10-0vl2
- rebuilt with openldap-2.3.27-0vl1

* Sun Apr 23 2006 Daisuke SUZUKI  2.2.10-0vl1
- new upstream release

* Thu Jan 12 2006 Daisuke SUZUKI  2.2.8-0vl1
- new upstream release

* Fri Sep 30 2005 Daisuke SUZUKI  2.2.5-0vl1
- new upstream release
  - update to 2.2.5
- update dynamicmaps from debian package
- update Japaese manpages and jconf
- add jhtml and jreadme
- enable TLS/SSL

* Mon Jan 31 2005 Daisuke SUZUKI  2.1.5-0vl1
- new upstream release
- update all patches
- link sasl2 instead of sasl1

* Mon Jan 24 2005 Tomohiro 'Tomo-p' KATO  2.0.20-0vl6
- enable cyrus-sasl.
- add TLS/IPv6 patch.
- modify main.cf to disable IPv6 as default.

* Wed Oct 28 2004 MATSUBAYASHI Kohji  2.0.20-0vl5
- add PreReq: db4 >= 4.2.52
  (to avoid errors when upgrading from db40-linked version)

* Mon Oct 11 2004 MATSUBAYASHI Kohji  2.0.20-0vl4
- rebuilt with db4-4.2.52

* Tue Jun  8 2004 Daisuke SUZUKI  2.0.20-0vl3
- fix first installation time bugs...
  - remove aliases.db from %%files again
  - add 'touch aliases.db' in %%post script
- update default main.cf to use /etc/postfix/aliases as default alias_database

* Mon Jun  7 2004 Daisuke SUZUKI  2.0.20-0vl2
- add /etc/postfix/aliases.db to %%files

* Sat May  8 2004 Daisuke SUZUKI  2.0.20-0vl1
- new upstream release

* Tue Apr 13 2004 Daisuke SUZUKI  2.0.19-0vl1
- new upstream release
- build with new postgresql

* Fri Sep 19 2003 Daisuke SUZUKI  2.0.16-0vl1
- new upstream release
- update jconf/jman/jhtml

* Fri Jul  4 2003 Daisuke SUZUKI  2.0.13-0vl1
- new upstream release
- update jman/jhtml/jreadme

* Mon Jun 16 2003 Daisuke SUZUKI  2.0.12-0vl1
- new upstream release
- update jconf/jman/jhtml/jreadme

* Tue Jun 03 2003 Daisuke SUZUKI  2.0.10-0vl1
- new upstream release

* Fri May 23 2003 Satoshi MACHINO  2.0.9-0vl5
- rebuild by new cyrus-sasl(2.1.13-3vl1)

* Sat Apr 26 2003 Daisuke SUZUKI  2.0.9-0vl4
- add more BuildPreReq, Requires
- fix some typo
- add missing files to %%files.

* Sat Apr 26 2003 Daisuke SUZUKI  2.0.9-0vl3
- rebuild

* Sat Apr 26 2003 Daisuke SUZUKI  2.0.9-0vl2
- add debian's dynamic map patch.
  some additional feature is divided to sub package.
  - postfix-ldap, postfix-mysql, postfix-pgsql, postfix-pcre
- split common postfix libraries as shared libs.
  - libpostfix-{master,global,util,dns}.so.1
- use cyrus-sasl for SMTP-AUTH

* Wed Apr 23 2003 Daisuke SUZUKI  2.0.9-0vl1
- new upstream release 2.0.9
- update jman/jhtml/jconf to 2.0.8

* Wed Apr  9 2003 IWAI Masaharu  2.0.7-0vl1
- new upstream version
- update documents
    - jman (source4)
    - jconf (Source5)
    - faq.html (Source6)
    - INSTALL.jp (Source7)
    - jhtml (Source12)

* Sun Jan 19 2003 MATSUBAYASHI Kohji  1.1.12-0vl3
- rebuilt against db4

* Wed Dec 18 2002 Daisuke SUZUKI  1.1.12-0vl2
- rebuild to remove unnecessary dependancy.

* Sat Nov 23 2002 Daisuke SUZUKI  1.1.12-0vl1
- new upstream version
- modified /etc/init.d/postfix

* Sun Oct 06 2002 Daisuke SUZUKI  1.1.11-0vl3
- fixed brainless mistakes...
  update main.cf again.

* Thu Oct 03 2002 Daisuke SUZUKI  1.1.11-0vl2
- update main.cf patch
  - do not use procmail for local mailer.
  - do not show version and OS name for smtpd greeting banner.

* Thu Jun 04 2002 Daisuke SUZUKI  1.1.11-0vl1
- new upstream release
- update jman, jconf, jhtml

* Tue May 28 2002 IWAI Masaharu  1.1.10-0vl2
- updated main.cf patch ( Patch0 )
    undefine myhostname

* Fri May 24 2002 IWAI Masaharu  1.1.10-0vl1
- changed %%{_var}/spool/postfix/private directory permission (0700 -> 0710)
    Thanks Mr. Daisuke SUZUKI ([VineSeed:06454])

* Thu May 23 2002 IWAI Masaharu  1.1.10-0vl0
- upstream release
- updated japanese documents Source4-9
    ( and the unofficial Japanese Web Site moved. )
- added japanese documents  Source10-12
- updated main.cf patch ( Patch0 )
- added postdrop group
- added some directories in %%{_var}/spool/postfix/
    active, corrupt, deferred, incoming, pid, public, bounce, 
    defer,flush,private and saved directories

* Mon Feb 18 2002 MATSUBAYASHI Kohji  0.0.20010228pl08-0vl3
- not stop in %%pre
- not start but restart in %%post

* Mon Dec 31 2001 MATSUBAYASHI Kohji  0.0.20010228pl08-0vl2
- added BuildPreReq: db3-devel

* Sat Nov 24 2001 Daisuke SUZUKI  0.0.20010228pl08-0vl1
- updated to 20010228-pl08

* Fri Nov  9 2001 Daisuke SUZUKI  0.0.20010228pl06-0vl1
- updated to 20010228-pl06

* Sun Sep 23 2001 Daisuke SUZUKI  0.0.20010228pl05-0vl1
- updated to 20010228-pl05

* Wed Aug  1 2001 Daisuke SUZUKI  0.0.20010228pl04-0vl1
- updated to 20010228-pl04

* Wed Jun 27 2001 Daisuke SUZUKI  0.0.20010228pl03-0vl2
- update Japanese documents and manpages

* Sun May 27 2001 Daisuke SUZUKI  0.0.20010228pl03-0vl1
- updated to 20010228-pl03

* Mon May 21 2001 MATSUBAYASHI 'Shaolin' Kohji 
- 0.0.20010228pl02-0vl3
- modified %%preun script again
  (to check whether %%{_sysconfidir}/rc.d/init.d/postfix already exists)

* Wed May 02 2001 MATSUBAYASHI 'Shaolin' Kohji 
- 0.0.20010228pl02-0vl2
- fixed incorrect %%preun script :–P

* Tue May  1 2001 Daisuke SUZUKI  0.0.20010228pl02-0vl1
- updated to 20010228-pl02

* Wed Apr 11 2001 Daisuke SUZUKI  0.0.20010228pl01-0vl4
- add {pcre,regexp}_table to %files
- don't replace config files
- start postfix after install/upgrade

* Mon Apr 09 2001 Daisuke SUZUKI  0.0.20010228pl01-0vl2
- updated jman pages and translations.
- added japanese sample config files.

* Sat Mar 31 2001 Daisuke SUZUKI  0.0.20010228pl01-0vl1
- updated to 20010228-pl01

* Thu Mar  1 2001 Daisuke SUZUKI  0.0.20010228-0vl2
- fixed file location

* Thu Mar  1 2001 Daisuke SUZUKI  0.0.20010228-0vl1
- updated to 20010228

* Tue Dec 26 2000 Tomoya TAKA  0.0.199912310pl13-0vl2
- fixed about mandir

* Thu Nov 23 2000 Daisuke SUZUKI  0.0.199912310pl13-0vl1
- updated to 19991231-pl13
- use rpm macros in spec

* Thu Nov 23 2000 Daisuke SUZUKI  0.0.199912310pl11-0vl1
- updated to 19991231-pl11

* Thu Nov  9 2000 Daisuke SUZUKI  0.0.199912310pl10-0vl1
- updated to 19991231-pl10

* Thu Oct 12 2000 Yoshihiro Kajiki 
- fix newaliases problem by adding slink

* Sat Oct  2 2000 Daisuke SUZUKI 
- add japanese man pages

* Sun Oct  1 2000 Jun Nishii 
- updates to 19991231-pl09-0vl2
- fixed Group

* Sat Sep 22 2000 Daisuke SUZUKI 
- updates to 19991231-pl09

* Wed Aug 09 2000 MACHINO, Satoshi 
- %build, removed bzip2 -9 and strip
- fixed %files section to handle compressed man page

* Wed Jun 21 2000 Daisuke SUZUKI 
- Version name changes to 0.0.version
- updates to 19991231-pl08
  + Major changes with postfix-19991231-pl08: 
    Specify "body_checks = regexp:%{_sysconfdir}/postfix/body_checks" for a quick
    and dirty emergency content filter that looks at non-header lines
    one line at a time (including MIME headers inside the message body).
    Details in conf/sample-filter.cf.
  + Incompatible changes with postfix-19991231-pl07:
    As required by RFC 822, Postfix now inserts a generic destination
    message header when no destination header is present.  The text is
    specified via the undisclosed_recipients_header configuration
    parameter (default:  "To: undisclosed-recipients:;").

* Thu Apr  6 2000 Daisuke SUZUKI 
- updates to 19991231-pl06
- added percent hack to main.cf

* Sun Feb 20 2000 Daisuke SUZUKI 
- adopted to Vine Linux

* Mon Jan  3 2000 Jean-Michel Dault 
- updated to 19991231
- added postfix group
- corrected aliases.db bug

* Mon Dec 27 1999 Jerome Dumonteil 
- Add postfix check in post to create sub dirs in spool

* Mon Dec 20 1999 Chmouel Boudjnah 
- Add -a $DOMAIN -d $LOGNAME to procmail (philippe).
- New banner.

* Wed Nov 10 1999 Chmouel Boudjnah 
- fix if conflicts with sendmail.

* Sat Jun  5 1999 Axalon Bloodstone 
- install bins from libexec/

* Sat Jun  5 1999 Bernhard Rosenkr舅zer 
- 19990601
- .spec cleanup for easier updates

* Wed May 26 1999 Axalon Bloodstone 
- created link from %{_sbindir}/sendmail to %{_libdir}/sendmail
  so it doesn't bug out when i rpm -e sendmail
- Now removes %{_var}/lock/subsys/postfix like a good little prog
  upon rpm -e

* Fri Apr 23 1999 Chmouel Boudjnah 

- Mandrake adptations.

* Tue Apr 13 1999 Arne Coucheron 
  [19990317-pl04-1]

* Tue Mar 30 1999 Arne Coucheron 
  [19990317-pl03-2]
- Castro, Castro, pay attention my friend. You're making it very hard
  maintaining the package if you don't follow the flow of the releases

* Thu Mar 25 1999 Arne Coucheron 
  [19990317-pl02-1]

* Tue Mar 23 1999 Arne Coucheron 
  [19990317-3]
- added bugfix patch01

* Sat Mar 20 1999 Arne Coucheron 
  [19990317-2]
- removed the mynetworks line in main.cf, let postfix figure it out
- striping of the files in %{_sbindir}
- alias database moved to %{_sysconfdir}/postfix and made a symlink to it in %{_sysconfdir}
- enabled procmail support in main.cf and added it to Requires:
- check status on master instead of postfix in the init script
- obsoletes postfix-beta
- had to move some of my latest changelog entries up here since Edgard Castro
  didn't follow my releases

* Thu Mar 18 1999 Edgard Castro 
  [19990317]

* Tue Mar 16 1999 Edgard Castro 
  [alpha-19990315]

* Tue Mar  9 1999 Edgard Castro 
  [19990122-pl01-2]
- shell and gecho information changed to complie with Red Hat stardand
- changed the name of the rpm package to postfix, instead of postfix-beta

* Tue Feb 16 1999 Edgard Castro 
  [19990122-pl01-1]

* Sun Jan 24 1999 Arne Coucheron 
  [19990122-1]
- shell for postfix user changed to /bin/true to avoid logins to the account
- files in %{_libdir}exec/postfix moved to %{_libdir}/postfix since this complies
  more with the Red Hat standard

* Wed Jan 06 1999 Arne Coucheron 
  [19981230-2]
- added URL for the source
- added a cron job for daily check of errors
- sample config files moved from /etc/postfix/sample to the docdir 
- dropped making of symlinks in %{_sbindir} and instead installing the real
  files there
- because of the previous they're not needed anymore in %{_libdir}exec/postfix,
  so they are removed from that place

* Fri Jan 01 1999 Arne Coucheron 
  [19981230-1]

* Tue Dec 29 1998 Arne Coucheron 
  [19981222-1]
- first build of rpm version

パッチがちゃんと当たっているか確認する。

$ rpmbuild -bp postfix.spec

実行中(%prep): /bin/sh -e /var/tmp/rpm-tmp.9410
+ umask 022
+ cd ~/rpm/BUILD
+ cd ~/rpm/BUILD
+ rm -rf postfix-2.6.5
+ /bin/gzip -dc ~/rpm/SOURCES/postfix-2.6.5.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd postfix-2.6.5
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (postfix-2.1.5-vine.patch):'
Patch #0 (postfix-2.1.5-vine.patch):
+ patch -p1 -b --suffix .vine -s
+ echo 'Patch #1 (postfix-2.2.10-main.cf-lib64.patch):'
Patch #1 (postfix-2.2.10-main.cf-lib64.patch):
+ patch -p1 -b --suffix .lib64 -s
+ echo 'Patch #2 (postfix-2.6.5-vda-ng.patch):'
Patch #2 (postfix-2.6.5-vda-ng.patch):
+ patch -p1 -b --suffix .vda-ng -s
+ echo 'Patch #100 (postfix-2.6.1-dynamicmaps.patch):'
Patch #100 (postfix-2.6.1-dynamicmaps.patch):
+ patch -p1 -b --suffix .dynamicmaps -s
+ perl -pi -e s,/usr/lib/,/usr/lib64/, conf/postfix-files
+ perl -pi -e 's,-lmysqlclient,-lmysqlclient -L/usr/lib64/mysql,' src/global/Makefile.in
+ echo 'Patch #200 (postfix-2.5.7-large-fs.patch):'
Patch #200 (postfix-2.5.7-large-fs.patch):
+ patch -p1 -b --suffix .large-fs -s
+ echo 'Patch #210 (postfix-2.5.5-open_define-vine.patch):'
Patch #210 (postfix-2.5.5-open_define-vine.patch):
+ patch -p1 -b --suffix .open_define -s
+ pushd src/global
~/rpm/BUILD/postfix-2.6.5/src/global ~/rpm/BUILD/postfix-2.6.5
+ :
+ :
+ popd
~/rpm/BUILD/postfix-2.6.5
+ exit 0

ビルドする。

$ rpmbuild -bb --clean postfix.spec

インストールする。

$ cd ../RPMS/x86_64
$ su
# rpm -ivh postfix-2.6.5-2vl5.x86_64.rpm postfix-mysql-2.6.5-2vl5.x86_64.rpm

コンフィグファイル。

# vi /etc/postfix/main.cf
# Global Postfix configuration file. This file lists only a subset
# of all parameters. For the syntax, and for a complete parameter
# list, see the postconf(5) manual page (command: "man 5 postconf").
#
# For common configuration examples, see BASIC_CONFIGURATION_README
# and STANDARD_CONFIGURATION_README. To find these documents, use
# the command "postconf html_directory readme_directory", or go to
# http://www.postfix.org/.
#
# For best results, change no more than 2-3 parameters at a time,
# and test if Postfix still works after every change.

# SOFT BOUNCE
#
# The soft_bounce parameter provides a limited safety net for
# testing.  When soft_bounce is enabled, mail will remain queued that
# would otherwise bounce. This parameter disables locally-generated
# bounces, and prevents the SMTP server from rejecting mail permanently
# (by changing 5xx replies into 4xx replies). However, soft_bounce
# is no cure for address rewriting mistakes or mail routing mistakes.
#
#soft_bounce = no

# LOCAL PATHNAME INFORMATION
#
# The queue_directory specifies the location of the Postfix queue.
# This is also the root directory of Postfix daemons that run chrooted.
# See the files in examples/chroot-setup for setting up Postfix chroot
# environments on different UNIX systems.
#
queue_directory = /var/spool/postfix

# The command_directory parameter specifies the location of all
# postXXX commands.
#
command_directory = /usr/sbin

# The daemon_directory parameter specifies the location of all Postfix
# daemon programs (i.e. programs listed in the master.cf file). This
# directory must be owned by root.
#
daemon_directory = /usr/lib64/postfix

# The data_directory parameter specifies the location of Postfix-writable
# data files (caches, random numbers). This directory must be owned
# by the mail_owner account (see below).
#
data_directory = /var/lib/postfix

# QUEUE AND PROCESS OWNERSHIP
#
# The mail_owner parameter specifies the owner of the Postfix queue
# and of most Postfix daemon processes.  Specify the name of a user
# account THAT DOES NOT SHARE ITS USER OR GROUP ID WITH OTHER ACCOUNTS
# AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM.  In
# particular, don't specify nobody or daemon. PLEASE USE A DEDICATED
# USER.
#
mail_owner = postfix

# The default_privs parameter specifies the default rights used by
# the local delivery agent for delivery to external file or command.
# These rights are used in the absence of a recipient user context.
# DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.
#
default_privs = nobody

# INTERNET HOST AND DOMAIN NAMES
# 
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
#mydomain = domain.tld

# SENDING MAIL
# 
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites.  If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
myorigin = $myhostname
#myorigin = $mydomain

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost

# The proxy_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on by way of a
# proxy or network address translation unit. This setting extends
# the address list specified with the inet_interfaces parameter.
#
# You must specify your proxy/NAT addresses when your system is a
# backup MX host for other domains, otherwise mail delivery loops
# will happen when the primary MX host is down.
#
#proxy_interfaces =
#proxy_interfaces = 1.2.3.4

# The mydestination parameter specifies the list of domains that this
# machine considers itself the final destination for.
#
# These domains are routed to the delivery agent specified with the
# local_transport parameter setting. By default, that is the UNIX
# compatible delivery agent that lookups all recipients in /etc/passwd
# and /etc/aliases or their equivalent.
#
# The default is $myhostname + localhost.$mydomain.  On a mail domain
# gateway, you should also include $mydomain.
#
# Do not specify the names of virtual domains - those domains are
# specified elsewhere (see VIRTUAL_README).
#
# Do not specify the names of domains that this machine is backup MX
# host for. Specify those names via the relay_domains settings for
# the SMTP server, or use permit_mx_backup if you are lazy (see
# STANDARD_CONFIGURATION_README).
#
# The local machine is always the final destination for mail addressed
# to user@[the.net.work.address] of an interface that the mail system
# receives mail on (see the inet_interfaces parameter).
#
# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key (the right-hand side is ignored).
# Continue long lines by starting the next line with whitespace.
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
#mydestination = $myhostname, localhost.$mydomain, localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
#	mail.$mydomain, www.$mydomain, ftp.$mydomain
mydestination =

# REJECTING MAIL FOR UNKNOWN LOCAL USERS
#
# The local_recipient_maps parameter specifies optional lookup tables
# with all names or addresses of users that are local with respect
# to $mydestination, $inet_interfaces or $proxy_interfaces.
#
# If this parameter is defined, then the SMTP server will reject
# mail for unknown local users. This parameter is defined by default.
#
# To turn off local recipient checking in the SMTP server, specify
# local_recipient_maps = (i.e. empty).
#
# The default setting assumes that you use the default Postfix local
# delivery agent for local delivery. You need to update the
# local_recipient_maps setting if:
#
# - You define $mydestination domain recipients in files other than
#   /etc/passwd, /etc/aliases, or the $virtual_alias_maps files.
#   For example, you define $mydestination domain recipients in    
#   the $virtual_mailbox_maps files.
#
# - You redefine the local delivery agent in master.cf.
#
# - You redefine the "local_transport" setting in main.cf.
#
# - You use the "luser_relay", "mailbox_transport", or "fallback_transport"
#   feature of the Postfix local delivery agent (see local(8)).
#
# Details are described in the LOCAL_RECIPIENT_README file.
#
# Beware: if the Postfix SMTP server runs chrooted, you probably have
# to access the passwd file via the proxymap service, in order to
# overcome chroot restrictions. The alternative, having a copy of
# the system passwd file in the chroot jail is just not practical.
#
# The right-hand side of the lookup tables is conveniently ignored.
# In the left-hand side, specify a bare username, an @domain.tld
# wild-card, or specify a user@domain.tld address.
# 
#local_recipient_maps = unix:passwd.byname $alias_maps
#local_recipient_maps = proxy:unix:passwd.byname $alias_maps
#local_recipient_maps =

# The unknown_local_recipient_reject_code specifies the SMTP server
# response code when a recipient domain matches $mydestination or
# ${proxy,inet}_interfaces, while $local_recipient_maps is non-empty
# and the recipient address or address local-part is not found.
#
# The default setting is 550 (reject mail) but it is safer to start
# with 450 (try again later) until you are certain that your
# local_recipient_maps settings are OK.
#
unknown_local_recipient_reject_code = 550

# TRUST AND RELAY CONTROL

# The mynetworks parameter specifies the list of "trusted" SMTP
# clients that have more privileges than "strangers".
#
# In particular, "trusted" SMTP clients are allowed to relay mail
# through Postfix.  See the smtpd_recipient_restrictions parameter
# in postconf(5).
#
# You can specify the list of "trusted" network addresses by hand
# or you can let Postfix do it for you (which is the default).
#
# By default (mynetworks_style = subnet), Postfix "trusts" SMTP
# clients in the same IP subnetworks as the local machine.
# On Linux, this does works correctly only with interfaces specified
# with the "ifconfig" command.
# 
# Specify "mynetworks_style = class" when Postfix should "trust" SMTP
# clients in the same IP class A/B/C networks as the local machine.
# Don't do this with a dialup site - it would cause Postfix to "trust"
# your entire provider's network.  Instead, specify an explicit
# mynetworks list by hand, as described below.
#  
# Specify "mynetworks_style = host" when Postfix should "trust"
# only the local machine.
# 
#mynetworks_style = class
#mynetworks_style = subnet
#mynetworks_style = host

# Alternatively, you can specify the mynetworks list by hand, in
# which case Postfix ignores the mynetworks_style setting.
#
# Specify an explicit list of network/netmask patterns, where the
# mask specifies the number of bits in the network part of a host
# address.
#
# You can also specify the absolute pathname of a pattern file instead
# of listing the patterns here. Specify type:table for table-based lookups
# (the value on the table right-hand side is not used).
#
mynetworks = 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table

# The relay_domains parameter restricts what destinations this system will
# relay mail to.  See the smtpd_recipient_restrictions description in
# postconf(5) for detailed information.
#
# By default, Postfix relays mail
# - from "trusted" clients (IP address matches $mynetworks) to any destination,
# - from "untrusted" clients to destinations that match $relay_domains or
#   subdomains thereof, except addresses with sender-specified routing.
# The default relay_domains value is $mydestination.
# 
# In addition to the above, the Postfix SMTP server by default accepts mail
# that Postfix is final destination for:
# - destinations that match $inet_interfaces or $proxy_interfaces,
# - destinations that match $mydestination
# - destinations that match $virtual_alias_domains,
# - destinations that match $virtual_mailbox_domains.
# These destinations do not need to be listed in $relay_domains.
# 
# Specify a list of hosts or domains, /file/name patterns or type:name
# lookup tables, separated by commas and/or whitespace.  Continue
# long lines by starting the next line with whitespace. A file name
# is replaced by its contents; a type:name table is matched when a
# (parent) domain appears as lookup key.
#
# NOTE: Postfix will not automatically forward mail for domains that
# list this system as their primary or backup MX host. See the
# permit_mx_backup restriction description in postconf(5).
#
#relay_domains = $mydestination

# INTERNET OR INTRANET

# The relayhost parameter specifies the default host to send mail to
# when no entry is matched in the optional transport(5) table. When
# no relayhost is given, mail is routed directly to the destination.
#
# On an intranet, specify the organizational domain name. If your
# internal DNS uses no MX records, specify the name of the intranet
# gateway host instead.
#
# In the case of SMTP, specify a domain, host, host:port, [host]:port,
# [address] or [address]:port; the form [host] turns off MX lookups.
#
# If you're connected via UUCP, see also the default_transport parameter.
#
#relayhost = $mydomain
#relayhost = [gateway.my.domain]
relayhost = [mailserver.isp.tld]:25
#relayhost = uucphost
#relayhost = [an.ip.add.ress]

# REJECTING UNKNOWN RELAY USERS
#
# The relay_recipient_maps parameter specifies optional lookup tables
# with all addresses in the domains that match $relay_domains.
#
# If this parameter is defined, then the SMTP server will reject
# mail for unknown relay users. This feature is off by default.
#
# The right-hand side of the lookup tables is conveniently ignored.
# In the left-hand side, specify an @domain.tld wild-card, or specify
# a user@domain.tld address.
# 
#relay_recipient_maps = hash:/etc/postfix/relay_recipients

# INPUT RATE CONTROL
#
# The in_flow_delay configuration parameter implements mail input
# flow control. This feature is turned on by default, although it
# still needs further development (it's disabled on SCO UNIX due
# to an SCO bug).
# 
# A Postfix process will pause for $in_flow_delay seconds before
# accepting a new message, when the message arrival rate exceeds the
# message delivery rate. With the default 100 SMTP server process
# limit, this limits the mail inflow to 100 messages a second more
# than the number of messages delivered per second.
# 
# Specify 0 to disable the feature. Valid delays are 0..10.
# 
#in_flow_delay = 1s

# ADDRESS REWRITING
#
# The ADDRESS_REWRITING_README document gives information about
# address masquerading or other forms of address rewriting including
# username->Firstname.Lastname mapping.

# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.

# "USER HAS MOVED" BOUNCE MESSAGES
#
# See the discussion in the ADDRESS_REWRITING_README document.

# TRANSPORT MAP
#
# See the discussion in the ADDRESS_REWRITING_README document.

# ALIAS DATABASE
#
# The alias_maps parameter specifies the list of alias databases used
# by the local delivery agent. The default list is system dependent.
#
# On systems with NIS, the default is to search the local alias
# database, then the NIS alias database. See aliases(5) for syntax
# details.
# 
# If you change the alias database, run "postalias /etc/aliases" (or
# wherever your system stores the mail alias file), or simply run
# "newaliases" to build the necessary DBM or DB file.
#
# It will take a minute or so before changes become visible.  Use
# "postfix reload" to eliminate the delay.
#
#alias_maps = dbm:/etc/aliases
alias_maps = hash:/etc/postfix/aliases
#alias_maps = hash:/etc/aliases, nis:mail.aliases
#alias_maps = netinfo:/aliases

# The alias_database parameter specifies the alias database(s) that
# are built with "newaliases" or "sendmail -bi".  This is a separate
# configuration parameter, because alias_maps (see above) may specify
# tables that are not necessarily all under control by Postfix.
#
#alias_database = dbm:/etc/aliases
#alias_database = dbm:/etc/mail/aliases
alias_database = hash:/etc/postfix/aliases
#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases

# ADDRESS EXTENSIONS (e.g., user+foo)
#
# The recipient_delimiter parameter specifies the separator between
# user names and address extensions (user+foo). See canonical(5),
# local(8), relocated(5) and virtual(5) for the effects this has on
# aliases, canonical, virtual, relocated and .forward file lookups.
# Basically, the software tries user+foo and .forward+foo before
# trying user and .forward.
#
#recipient_delimiter = +

# DELIVERY TO MAILBOX
#
# The home_mailbox parameter specifies the optional pathname of a
# mailbox file relative to a user's home directory. The default
# mailbox file is /var/spool/mail/user or /var/mail/user.  Specify
# "Maildir/" for qmail-style delivery (the / is required).
#
#home_mailbox = Mailbox
home_mailbox = Maildir/

# The mail_spool_directory parameter specifies the directory where
# UNIX-style mailboxes are kept. The default setting depends on the
# system type.
#
#mail_spool_directory = /var/mail
mail_spool_directory = /var/spool/mail

# The mailbox_command parameter specifies the optional external
# command to use instead of mailbox delivery. The command is run as
# the recipient with proper HOME, SHELL and LOGNAME environment settings.
# Exception:  delivery for root is done as $default_user.
#
# Other environment variables of interest: USER (recipient username),
# EXTENSION (address extension), DOMAIN (domain part of address),
# and LOCAL (the address localpart).
#
# Unlike other Postfix configuration parameters, the mailbox_command
# parameter is not subjected to $parameter substitutions. This is to
# make it easier to specify shell syntax (see example below).
#
# Avoid shell meta characters because they will force Postfix to run
# an expensive shell process. Procmail alone is expensive enough.
#
# IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN
# ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.
#
#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a "$EXTENSION"

# The mailbox_transport specifies the optional transport in master.cf
# to use after processing aliases and .forward files. This parameter
# has precedence over the mailbox_command, fallback_transport and
# luser_relay parameters.
#
# Specify a string of the form transport:nexthop, where transport is
# the name of a mail delivery transport defined in master.cf.  The
# :nexthop part is optional. For more details see the sample transport
# configuration file.
#
# NOTE: if you use this feature for accounts not in the UNIX password
# file, then you must update the "local_recipient_maps" setting in
# the main.cf file, otherwise the SMTP server will reject mail for    
# non-UNIX accounts with "User unknown in local recipient table".
#
#mailbox_transport = lmtp:unix:/file/name
#mailbox_transport = cyrus

# The fallback_transport specifies the optional transport in master.cf
# to use for recipients that are not found in the UNIX passwd database.
# This parameter has precedence over the luser_relay parameter.
#
# Specify a string of the form transport:nexthop, where transport is
# the name of a mail delivery transport defined in master.cf.  The
# :nexthop part is optional. For more details see the sample transport
# configuration file.
#
# NOTE: if you use this feature for accounts not in the UNIX password
# file, then you must update the "local_recipient_maps" setting in
# the main.cf file, otherwise the SMTP server will reject mail for    
# non-UNIX accounts with "User unknown in local recipient table".
#
#fallback_transport = lmtp:unix:/file/name
#fallback_transport = cyrus
#fallback_transport =

# The luser_relay parameter specifies an optional destination address
# for unknown recipients.  By default, mail for unknown@$mydestination,
# unknown@[$inet_interfaces] or unknown@[$proxy_interfaces] is returned
# as undeliverable.
#
# The following expansions are done on luser_relay: $user (recipient
# username), $shell (recipient shell), $home (recipient home directory),
# $recipient (full recipient address), $extension (recipient address
# extension), $domain (recipient domain), $local (entire recipient
# localpart), $recipient_delimiter. Specify ${name?value} or
# ${name:value} to expand value only when $name does (does not) exist.
#
# luser_relay works only for the default Postfix local delivery agent.
#
# NOTE: if you use this feature for accounts not in the UNIX password
# file, then you must specify "local_recipient_maps =" (i.e. empty) in
# the main.cf file, otherwise the SMTP server will reject mail for    
# non-UNIX accounts with "User unknown in local recipient table".
#
#luser_relay = $user@other.host
#luser_relay = $local@other.host
#luser_relay = admin+$local
  
# JUNK MAIL CONTROLS
# 
# The controls listed here are only a very small subset. The file
# SMTPD_ACCESS_README provides an overview.

# The header_checks parameter specifies an optional table with patterns
# that each logical message header is matched against, including
# headers that span multiple physical lines.
#
# By default, these patterns also apply to MIME headers and to the
# headers of attached messages. With older Postfix versions, MIME and
# attached message headers were treated as body text.
#
# For details, see "man header_checks".
#
header_checks = regexp:/etc/postfix/header_checks

# FAST ETRN SERVICE
#
# Postfix maintains per-destination logfiles with information about
# deferred mail, so that mail can be flushed quickly with the SMTP
# "ETRN domain.tld" command, or by executing "sendmail -qRdomain.tld".
# See the ETRN_README document for a detailed description.
# 
# The fast_flush_domains parameter controls what destinations are
# eligible for this service. By default, they are all domains that
# this server is willing to relay mail to.
# 
#fast_flush_domains = $relay_domains

# SHOW SOFTWARE VERSION OR NOT
#
# The smtpd_banner parameter specifies the text that follows the 220
# code in the SMTP server's greeting banner. Some people like to see
# the mail version advertised. By default, Postfix shows no version.
#
# You MUST specify $myhostname at the start of the text. That is an
# RFC requirement. Postfix itself does not care.
#
smtpd_banner = $myhostname ESMTP
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)

# PARALLEL DELIVERY TO THE SAME DESTINATION
#
# How many parallel deliveries to the same user or domain? With local
# delivery, it does not make sense to do massively parallel delivery
# to the same user, because mailbox updates must happen sequentially,
# and expensive pipelines in .forward files can cause disasters when
# too many are run at the same time. With SMTP deliveries, 10
# simultaneous connections to the same domain could be sufficient to
# raise eyebrows.
# 
# Each message delivery transport has its XXX_destination_concurrency_limit
# parameter.  The default is $default_destination_concurrency_limit for
# most delivery transports. For the local delivery agent the default is 2.

#local_destination_concurrency_limit = 2
#default_destination_concurrency_limit = 20

# DEBUGGING CONTROL
#
# The debug_peer_level parameter specifies the increment in verbose
# logging level when an SMTP client or server host name or address
# matches a pattern in the debug_peer_list parameter.
#
debug_peer_level = 2

# The debug_peer_list parameter specifies an optional list of domain
# or network patterns, /file/name patterns or type:name tables. When
# an SMTP client or server host name or address matches a pattern,
# increase the verbose logging level by the amount specified in the
# debug_peer_level parameter.
#
#debug_peer_list = 127.0.0.1
#debug_peer_list = some.domain

# The debugger_command specifies the external command that is executed
# when a Postfix daemon program is run with the -D option.
#
# Use "command .. & sleep 5" so that the debugger can attach before
# the process marches on. If you use an X-based debugger, be sure to
# set up your XAUTHORITY environment variable before starting Postfix.
#
debugger_command =
	 PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
	 ddd $daemon_directory/$process_name $process_id & sleep 5

# If you can't use X, use this to capture the call stack when a
# daemon crashes. The result is in a file in the configuration
# directory, and is named after the process name and the process ID.
#
# debugger_command =
#	PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont;
#	echo where) | gdb $daemon_directory/$process_name $process_id 2>&1
#	>$config_directory/$process_name.$process_id.log & sleep 5
#
# Another possibility is to run gdb under a detached screen session.
# To attach to the screen sesssion, su root and run "screen -r
# " where  uniquely matches one of the detached
# sessions (from "screen -list").
#
# debugger_command =
#	PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen
#	-dmS $process_name gdb $daemon_directory/$process_name
#	$process_id & sleep 1

# INSTALL-TIME CONFIGURATION INFORMATION
#
# The following parameters are used when installing a new Postfix version.
# 
# sendmail_path: The full pathname of the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
# 
sendmail_path = /usr/sbin/sendmail

# newaliases_path: The full pathname of the Postfix newaliases command.
# This is the Sendmail-compatible command to build alias databases.
#
newaliases_path = /usr/bin/newaliases

# mailq_path: The full pathname of the Postfix mailq command.  This
# is the Sendmail-compatible mail queue listing command.
# 
mailq_path = /usr/sbin/mailq

# setgid_group: The group for mail submission and queue management
# commands.  This must be a group name with a numerical group ID that
# is not shared with other accounts, not even with the Postfix account.
#
setgid_group = postdrop

# html_directory: The location of the Postfix HTML documentation.
#
html_directory = no

# manpage_directory: The location of the Postfix on-line manual pages.
#
manpage_directory = /usr/local/man

# sample_directory: The location of the Postfix sample configuration files.
# This parameter is obsolete as of Postfix 2.1.
#
sample_directory = /etc/postfix

# readme_directory: The location of the Postfix README files.
#
readme_directory = no

allow_percent_hack = no
disable_vrfy_command = yes

smtpd_tls_cert_file = /path/to/certificitate/server.crt
smtpd_tls_key_file = /path/to/certificitate/server.key
#smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
#smtpd_use_tls = yes
smtpd_tls_loglevel = 0
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
tls_random_source = dev:/dev/urandom

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous

local_recipient_maps = $alias_maps,
 mysql:/etc/postfix/mysql_virtual_alias_maps.cf,
 mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
local_transport = virtual
virtual_transport = virtual
virtual_alias_maps = hash:/etc/aliases,
 mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_base = /path/to/directory
virtual_mailbox_limit = 512000000
virtual_minimum_uid = 1000
virtual_gid_maps = static:1000
virtual_uid_maps = static:1000

virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes

smtpd_delay_reject = no
show_user_unknown_table_name = no
smtpd_client_restrictions = permit_mynetworks
smtpd_sender_login_maps = mysql:/etc/postfix/mysql_sender_login_maps.cf
smtpd_sender_restrictions = permit_mynetworks,
 reject_sender_login_mismatch
smtpd_recipient_restrictions = permit_mynetworks,
 permit_sasl_authenticated,
 reject_unauth_destination
# vi /etc/postfix/master.cf
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
#submission inet n       -       n       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd
   -o smtpd_tls_wrappermode=yes
   -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628      inet  n       -       n       -       -       qmqpd
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       n       -       -       smtp
	-o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop  unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# The Cyrus deliver program has changed incompatibly, multiple times.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
#uucp      unix  -       n       n       -       -       pipe
#  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# ====================================================================
#
# Other external delivery methods.
#
#ifmail    unix  -       n       n       -       -       pipe
#  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#
#bsmtp     unix  -       n       n       -       -       pipe
#  flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
#
#scalemail-backend unix -       n       n       -       2       pipe
#  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store
#  ${nexthop} ${user} ${extension}
#
#mailman   unix  -       n       n       -       -       pipe
#  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
#  ${nexthop} ${user}

PostfixからMySQLへの問い合わせをするファイルを作成する。

# touch /etc/postfix/mysql_virtual_domains_maps.cf
# vi /etc/postfix/mysql_virtual_domains_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT description FROM domain WHERE domain='%s'
# touch /etc/postfix/mysql_virtual_alias_maps.cf
# vi /etc/postfix/mysql_virtual_alias_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT goto FROM alias WHERE address='%s' AND active = 1
# touch /etc/postfix/mysql_sender_login_maps.cf
# vi /etc/postfix/mysql_sender_login_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT CONCAT(username, ' OK') FROM mailbox WHERE username='%s'
# touch /etc/postfix/mysql_relay_domains_maps.cf
# vi /etc/postfix/mysql_relay_domains_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
# touch /etc/postfix/mysql_virtual_mailbox_maps.cf
# vi /etc/postfix/mysql_virtual_mailbox_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
# touch /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
# vi /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = sql_user_name
password = sql_user_pass
hosts = localhost
dbname = db_name
query = SELECT quota FROM mailbox WHERE username='%s'

postfixが読めるようにする。

# chown root:postfix /etc/postfix/mysql*
# chmod 0640 /etc/postfix/mysql*

Postfixが参照するDBをMySQLに作成する。

# mysqladmin -u root --password='root_pass' create db_name
# mysql -u root -p
> USE db_name;

エイリアステーブルを作成

> CREATE TABLE `alias` (`address` varchar(255) NOT NULL default '',
> `goto` text NOT NULL,
> `domain` varchar(255) NOT NULL default '',
> `created` datetime NOT NULL default '0000-00-00 00:00:00',
> `modified` datetime NOT NULL default '0000-00-00 00:00:00',
> `active` tinyint(1) NOT NULL default '1',
> PRIMARY KEY  (`address`)
> ) TYPE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Virtual Aliases';

ドメインテーブルを作成

> CREATE TABLE `domain` (
> `domain` varchar(255) NOT NULL default '',
> `description` varchar(255) NOT NULL default '',
> `aliases` int(10) NOT NULL default '0',
> `mailboxes` int(10) NOT NULL default '0',
> `maxquota` int(10) NOT NULL default '0',
> `transport` varchar(255) default NULL,
> `backupmx` tinyint(1) NOT NULL default '0',
> `created` datetime NOT NULL default '0000-00-00 00:00:00',
> `modified` datetime NOT NULL default '0000-00-00 00:00:00',
> `active` tinyint(1) NOT NULL default '1',
> PRIMARY KEY  (`domain`)
> ) TYPE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Virtual Domains';

メールボックステーブルを作成。

> CREATE TABLE `mailbox` (
> `username` varchar(255) NOT NULL default '',
> `password` varchar(255) NOT NULL default '',
> `name` varchar(255) NOT NULL default '',
> `maildir` varchar(255) NOT NULL default '',
> `quota` int(10) NOT NULL default '0',
> `domain` varchar(255) NOT NULL default '',
> `created` datetime NOT NULL default '0000-00-00 00:00:00',
> `modified` datetime NOT NULL default '0000-00-00 00:00:00',
> `active` tinyint(1) NOT NULL default '1',
> PRIMARY KEY  (`username`)
> ) TYPE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Virtual Mailboxes';

データベースへの権限設定をする。

> GRANT SELECT,UPDATE,INSERT ON db_name.* TO sql_user_name@localhost IDENTIFIED BY 'sql_user_pass';

ユーザーを作成。

> INSERT INTO `domain` (domain,description) VALUES ('example.com','');
> INSERT INTO `alias` (address,goto) VALUES ('alias@example.com', 'user@example.com');
> INSERT INTO `mailbox` (username,password,name,maildir,quota,domain) VALUES ('user@example.com','user_pass','','example.com/user/','102400000','example.com');
> flush privileges;
> \q

virtual専用ユーザーと必要なメールディレクトリを作成。

# groupadd -g 1000 virtual_group
# useradd -g virtual_group -u 1000 -s /bin/false virtual_user
# mkdir /path/to/directory
# chown virtual_user:virtual_group /path/to/directory
# chmod 771 /path/to/directory

起動スクリプト。

#!/bin/sh
#
# postfix       This shell script takes care of starting and stopping
#               postfix.
#
# chkconfig: 2345 80 30
#
# description: Postfix is a Mail Transport Agent, which is the program
#              that moves mail from one machine to another.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

#
prog="Postfix"

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/sbin/postfix ] || exit 0

# See how we were called.
case "$1" in
  start)
	# Start daemons.
	echo -n $"Starting $prog: "
	newaliases
	for I in access canonical relocated transport virtual
	do
	if [ -f /etc/postfix/$I ] ; then
	   /usr/sbin/postmap hash:/etc/postfix/$I < /etc/postfix/$I
	fi
	done
	daemon /usr/sbin/postfix start 2>/dev/null
	echo
	touch /var/lock/subsys/postfix
	;;
  stop)
	# Stop daemons.
	echo -n $"Shutting down $prog: "
	/usr/sbin/postfix stop 2>/dev/null
	[ $? = 0 ] && success $"$prog stopped" || failure $"$prog stopped"
	echo
	rm -f /var/lock/subsys/postfix
	;;
  restart)
	$0 stop
	$0 start
	;;
  reload)
	/usr/sbin/postfix reload
	;;
  status)
	status master
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit 0

起動設定後、起動して設定チェックとパーミッションチェック。

# chkconfig postfix on
# service postfix start

Postfixを起動中:				[  OK  ]

# postfix set-permissions;postfix check

送信テストをする。

# telnet localhost smtp

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain ESMTP
ehlo example.com
250-localhost.localdomain
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:<user@example.com>
250 2.1.0 Ok
rcpt to:<user@example.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
test

.
250 2.0.0 Ok: queued as 49F332A190
quit
221 2.0.0 Bye
Connection closed by foreign host.