ウェブ、ショウジン

Ubuntu Serverにsendmailのインストール

2009-6-3
Category
Server

VMware fusion 上の Ubuntu Server 8.10 にsendmail をインストールしたメモ。

CodeIgniter のチュートリアルをやっていて、メール送信する必要のあるものがあったんだけど、xampp(for OSX なんで mampp になるのか?)だと、なんか sendmail が入ってないっぽい。MacPorts で管理している環境(opt 以下)だと、よく見る /usr/sbin/sendmail なんだけど、xampp for OSX には見あたらない。

なので、もう xampp はやめて、仮想マシン上の Ubuntu で勉強することにした。

Ubuntu で /usr/sbin/sendmail を探す。
見あたらない。

cd で /usr/sbin に移動して sendmail を実行。確認してみる。

以下のメッセージが出る。

$ sendmail
The program 'sendmail' can be found in the following packages:
 * nbsmtp
 * smail
 * nullmailer
 * exim4-daemon-heavy
 * masqmail
 * courier-mta
 * msmtp-mta
 * esmtp-run
 * ssmtp
 * sendmail-bin
 * xmail
 * postfix
 * exim4-daemon-light
Try: sudo apt-get install 
-bash: sendmail: command not found

Try: sudo apt-get install
このメッセージに従って

$ sudo apt-get install sendmail

を実行する。

$ sudo apt-get install sendmail
[sudo] password for showjin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
 liblockfile1 m4 make procmail sendmail-base sendmail-bin sendmail-cf
sensible-mda
Suggested packages:
 make-doc rmail sendmail-doc ca-certificates logcheck resolvconf
openssl sasl2-bin
Recommended packages:
 postfix mail-transport-agent fetchmail
The following NEW packages will be installed:
 liblockfile1 m4 make procmail sendmail sendmail-base sendmail-bin
sendmail-cf sensible-mda
0 upgraded, 9 newly installed, 0 to remove and 2 not upgraded.
Need to get 2176kB of archives.
After this operation, 7426kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://jp.archive.ubuntu.com hardy/main liblockfile1 1.06.2 [15.6kB]
Get:2 http://jp.archive.ubuntu.com hardy/main m4 1.4.10-1 [250kB]
Get:3 http://jp.archive.ubuntu.com hardy/main make 3.81-3build1 [163kB]
Get:4 http://jp.archive.ubuntu.com hardy/main procmail 3.22-16ubuntu3 [154kB]
Get:5 http://jp.archive.ubuntu.com hardy/universe sendmail-base
8.14.2-2build1 [354kB]
Get:6 http://jp.archive.ubuntu.com hardy/universe sendmail-cf
8.14.2-2build1 [292kB]
Get:7 http://jp.archive.ubuntu.com hardy/universe sendmail-bin
8.14.2-2build1 [932kB]
Get:8 http://jp.archive.ubuntu.com hardy/universe sensible-mda
8.14.2-2build1 [11.8kB]
Get:9 http://jp.archive.ubuntu.com hardy/universe sendmail
8.14.2-2build1 [3494B]
Fetched 2176kB in 3s (696kB/s)
Selecting previously deselected package liblockfile1.
(Reading database ... 24228 files and directories currently installed.)
Unpacking liblockfile1 (from .../liblockfile1_1.06.2_amd64.deb) ...
Selecting previously deselected package m4.
Unpacking m4 (from .../archives/m4_1.4.10-1_amd64.deb) ...
Selecting previously deselected package make.
Unpacking make (from .../make_3.81-3build1_amd64.deb) ...
Selecting previously deselected package procmail.
Unpacking procmail (from .../procmail_3.22-16ubuntu3_amd64.deb) ...
Selecting previously deselected package sendmail-base.
Unpacking sendmail-base (from .../sendmail-base_8.14.2-2build1_all.deb) ...
Selecting previously deselected package sendmail-cf.
Unpacking sendmail-cf (from .../sendmail-cf_8.14.2-2build1_all.deb) ...
Selecting previously deselected package sendmail-bin.
Unpacking sendmail-bin (from .../sendmail-bin_8.14.2-2build1_amd64.deb) ...
Selecting previously deselected package sensible-mda.
Unpacking sensible-mda (from .../sensible-mda_8.14.2-2build1_amd64.deb) ...
Selecting previously deselected package sendmail.
Unpacking sendmail (from .../sendmail_8.14.2-2build1_all.deb) ...
Setting up liblockfile1 (1.06.2) ...
Setting up m4 (1.4.10-1) ...

Setting up make (3.81-3build1) ...
Setting up procmail (3.22-16ubuntu3) ...
Setting up sendmail-base (8.14.2-2build1) ...
adduser: Warning: The home directory `/var/lib/sendmail' does not
belong to the user you are currently creating.
adduser: Warning: The home directory `/var/lib/sendmail' does not
belong to the user you are currently creating.

Setting up sendmail-cf (8.14.2-2build1) ...
Setting up sendmail-bin (8.14.2-2build1) ...

You are doing a new install, or have erased /etc/mail/sendmail.mc.
If you've accidentaly erased /etc/mail/sendmail.mc, check /var/backups.

I am creating a safe, default sendmail.mc for you and you can
run sendmailconfig later if you need to change the defaults.

 * Stopping Mail Transport Agent (MTA) sendmail
  ...done.
Updating sendmail environment ...
Validating configuration.
Writing configuration to /etc/mail/sendmail.conf.
Writing /etc/cron.d/sendmail.
Could not open /etc/mail/databases(No such file or directory), creating it.
Could not open /etc/mail/sendmail.mc(No such file or directory)
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Writing configuration to /etc/mail/sendmail.conf.
Writing /etc/cron.d/sendmail.
Turning off Host Status collection
Could not open /etc/mail/databases(No such file or directory), creating it.
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...

Checking filesystem, this may take some time - it will not hang!
 ...   Done.

Checking for installed MDAs...
Adding link for newly extant program (mail.local)
Adding link for newly extant program (procmail)
sasl2-bin not installed, not configuring sendmail support.

To enable sendmail SASL2 support at a later date, invoke
"/usr/share/sendmail/update_auth"


OpenSSL is not installed, will not configure sendmail support for it.

to install openssl, get openssl.

To enable sendmail TLS support at a later date, invoke
"/usr/share/sendmail/update_tls"


Updating /etc/hosts.allow, adding "sendmail: all".

Please edit /etc/hosts.allow and check the rules location to
make sure your security measures have not been overridden -
it is common to move the sendmail:all line to the *end* of
the file, so your more selective rules take precedence.
Checking {sendmail,submit}.mc and related databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/Makefile...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Writing configuration to /etc/mail/sendmail.conf.
Writing /etc/cron.d/sendmail.
Disabling HOST statistics file(/var/lib/sendmail/host_status).
Creating /etc/mail/sendmail.cf...
Creating /etc/mail/submit.cf...
Informational: confCR_FILE file empty: /etc/mail/relay-domains
Warning: confCT_FILE source file not found: /etc/mail/trusted-users
 it was created
Informational: confCT_FILE file empty: /etc/mail/trusted-users
Warning: confCW_FILE source file not found: /etc/mail/local-host-names
 it was created
Warning: access_db source file not found: /etc/mail/access
 it was created
Updating /etc/mail/access...
Linking /etc/aliases to /etc/mail/aliases
Updating /etc/mail/aliases...
/etc/mail/aliases: 1 aliases, longest 7 bytes, 11 bytes total

Warning: 3 database(s) sources
       were not found, (but were created)
       please investigate.
 * Starting Mail Transport Agent (MTA) sendmail
  ...done.

Setting up sensible-mda (8.14.2-2build1) ...
Setting up sendmail (8.14.2-2build1) ...

再度 /usr/sbin ディレクトリを確認すると「sendmail」を見つけることが出来た。

07/06/2009 追記:
よくみると警告メッセージが出ている。まだこの sendmail でメールの送信は試してないけど、失敗の予感。
(Ubuntu 上では * Starting Mail Transport Agent (MTA) sendmail ってメッセージが表示されるようになった)

Warning: 3 database(s) sources
       were not found, (but were created)
       please investigate.
 * Starting Mail Transport Agent (MTA) sendmail
  ...done.

まだ送信確認まではしてないけど、/etc/php5/apache2/php.ini の sendmail_path を編集すればこれでいける、か?

php.ini

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t

07/06/2009 追記:
コマンドラインから $ mail hoge@hoge.hoge ってやると、メール送信の確認が出来るような記述を見かけたので、試しにやってみた。以下のようなメッセージが出て、mailx と mailutils というのが足りないようなので、メッセージ通りに apt-get で install してみる。

$ mail showjin@gmail.com
The program 'mail' can be found in the following packages:
 * mailx
 * mailutils
Try: sudo apt-get install 
-bash: mail: command not found

mailx のインストール

$ sudo apt-get install mailx
[sudo] password for showjin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mailx
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 164kB of archives.
After this operation, 315kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com hardy/main mailx 1:8.1.2-0.20071017cvs-2 [164kB]
Fetched 164kB in 0s (182kB/s)
Selecting previously deselected package mailx.
(Reading database ... 24783 files and directories currently installed.)
Unpacking mailx (from .../mailx_1%3a8.1.2-0.20071017cvs-2_amd64.deb) ...
Setting up mailx (1:8.1.2-0.20071017cvs-2) ...

mailutils のインストール

$ sudo apt-get install mailutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  guile-1.6-libs libgsasl7 libguile-ltdl-1 libltdl3 libmailutils1 libntlm0
Suggested packages:
  mailutils-mh
The following packages will be REMOVED:
  mailx
The following NEW packages will be installed:
  guile-1.6-libs libgsasl7 libguile-ltdl-1 libltdl3 libmailutils1 libntlm0
  mailutils
0 upgraded, 7 newly installed, 1 to remove and 2 not upgraded.
Need to get 1982kB of archives.
After this operation, 5956kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://jp.archive.ubuntu.com hardy/main libguile-ltdl-1 1.6.8-6ubuntu1 [13.3kB]
Get:2 http://jp.archive.ubuntu.com hardy/main guile-1.6-libs 1.6.8-6ubuntu1 [624kB]
Get:3 http://jp.archive.ubuntu.com hardy/universe libntlm0 0.3.13-1 [17.7kB]
Get:4 http://jp.archive.ubuntu.com hardy-updates/universe libgsasl7 0.2.21-1ubuntu0.1 [115kB]
Get:5 http://jp.archive.ubuntu.com hardy/main libltdl3 1.5.26-1ubuntu1 [180kB]
Get:6 http://jp.archive.ubuntu.com hardy/universe libmailutils1 1:1.1+dfsg1-3.1 [727kB]
Get:7 http://jp.archive.ubuntu.com hardy/universe mailutils 1:1.1+dfsg1-3.1 [305kB]
Fetched 1982kB in 3s (598kB/s)
(Reading database ... 24801 files and directories currently installed.)
Removing mailx ...
Selecting previously deselected package libguile-ltdl-1.
(Reading database ... 24784 files and directories currently installed.)
Unpacking libguile-ltdl-1 (from .../libguile-ltdl-1_1.6.8-6ubuntu1_amd64.deb) ...
Selecting previously deselected package guile-1.6-libs.
Unpacking guile-1.6-libs (from .../guile-1.6-libs_1.6.8-6ubuntu1_amd64.deb) ...
Selecting previously deselected package libntlm0.
Unpacking libntlm0 (from .../libntlm0_0.3.13-1_amd64.deb) ...
tar: ./shlibs: time stamp 2009-03-31 16:30:41 is 9494168.082425799 s in the future
tar: ./postinst: time stamp 2009-03-31 16:30:41 is 9494168.080053114 s in the future
tar: ./postrm: time stamp 2009-03-31 16:30:41 is 9494168.079037327 s in the future
tar: ./md5sums: time stamp 2009-03-31 16:30:42 is 9494169.078162063 s in the future
tar: ./control: time stamp 2009-03-31 16:30:42 is 9494169.07724154 s in the future
tar: .: time stamp 2009-03-31 16:30:42 is 9494169.075771778 s in the future
Selecting previously deselected package libgsasl7.
Unpacking libgsasl7 (from .../libgsasl7_0.2.21-1ubuntu0.1_amd64.deb) ...
Selecting previously deselected package libltdl3.
Unpacking libltdl3 (from .../libltdl3_1.5.26-1ubuntu1_amd64.deb) ...
Selecting previously deselected package libmailutils1.
Unpacking libmailutils1 (from .../libmailutils1_1%3a1.1+dfsg1-3.1_amd64.deb) ...
Selecting previously deselected package mailutils.
Unpacking mailutils (from .../mailutils_1%3a1.1+dfsg1-3.1_amd64.deb) ...
Setting up libguile-ltdl-1 (1.6.8-6ubuntu1) ...

Setting up guile-1.6-libs (1.6.8-6ubuntu1) ...

Setting up libntlm0 (0.3.13-1) ...

Setting up libgsasl7 (0.2.21-1ubuntu0.1) ...

Setting up libltdl3 (1.5.26-1ubuntu1) ...

Setting up libmailutils1 (1:1.1+dfsg1-3.1) ...

Setting up mailutils (1:1.1+dfsg1-3.1) ...
Installing new version of config file /etc/mail.rc ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place

再度コマンドラインから送信テストをしてみるが、駄目だった。

Categories

Tag Cloud

AdMob Android Apache centos CodeIgniter EC-CUBE facebookアプリ facebookページ feed Firefox Flash google googleanalytics htaccess iPad iPhone JavaScript lamp mobile nginx ogp pear php plugin rollover rss sendmail setting smarty ssh Titanium Mobile Titanium Studio tutorial ubuntu vim VirtualBox vmware vps Windows WordPress xampp youtube さくらインターネット アクセス解析 カスタム投稿