ユーザ用ツール

サイト用ツール


サイドバー

Index

はじめてのおつかい






DokuWiki整形記法


PlayGround



development:mailcatcher

MailCatcher

ダミーSMTPサーバ

開発などで本番のメールサーバ(SMTPサーバ)を使わずに開発可能

このページについて

AWS上でのインストール記録。

環境

OS:Red Hat Enterprise Linux Server release 6.7 (On AWS)

Ruby:標準のRubyは1.8.7と古いのでrbenv+ruby-buildでRubyをインストールする

インストール

git

# yum install git

rbenv

今回はrbenvを/opt配下にインストールする。

GitHubからrbenvをclone

# cd /opt
# git clone git://github.com/sstephenson/rbenv.git

rbenvへパスを通す設定と初期化を行う行を追記

# echo 'export RBENV_ROOT="/opt/rbenv"' >> /etc/profile
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
# echo 'eval "$(rbenv init -)"' >> /etc/profile

ruby-build

# mkdir /opt/rbenv/plugins
# cd /opt/rbenv/plugins
# git clone git://github.com/sstephenson/ruby-build.git

ビルド用のパッケージインストール

# yum install gcc gcc-c++ openssl-devel readline-devel sqlite-devel

インストール可能なパッケージの確認

# rbenv install -l
......
2.2.3
2.2.4
2.2.5
2.3.0-dev
2.3.0-preview1
2.3.0-preview2
2.3.0
......

Ruby

今回は2.2.5をインストールする

# rbenv install 2.2.5
Downloading ruby-2.2.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.5.tar.bz2
Installing ruby-2.2.5...
Installed ruby-2.2.5 to /opt/rbenv/versions/2.2.5

rbenv globalで、環境全体での Ruby バージョンを指定

# rbenv global 2.2.5

確認

# ruby -v
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]

MailCatcher

# gem install mailcatcher

設定

ポートを開ける

mailcatcherは標準でsmtpを1025、web uiを1080ポートで待ち受ける。1)

# iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
# iptables -A INPUT -p tcp --dport 1025 -j ACCEPT
# service iptables save
# service iptables restart

起動

起動するとデーモンとして動き続ける。終了はWebUIのQuitで行う。

defaultポートはsmtpが1025、httpが1080となり、webはlocalhostからのみアクセス可能

$ mailcatcher

全てのIPからWEBへアクセス可能とするには以下のように2)

$ mailcatcher --http-ip=0.0.0.0 --http-port 51080

起動オプション

$ mailcatcher --help
Usage: mailcatcher [options]
        --ip IP                      Set the ip address of both servers
        --smtp-ip IP                 Set the ip address of the smtp server
        --smtp-port PORT             Set the port of the smtp server
        --http-ip IP                 Set the ip address of the http server
        --http-port PORT             Set the port address of the http server
        --no-quit                    Don't allow quitting the process
    -f, --foreground                 Run in the foreground
    -v, --verbose                    Be more verbose
    -h, --help                       Display this help information

    -h, --help                       Display this help information

API

uri機能
/messages/メッセージ一覧
/messages/<id>.json指定IDメッセージのメタデータ取得
/messages/<id>.html指定IDメッセージのHTML取得
/messages/<id>.plain指定IDメッセージのTEXT取得
/messages/<id>/<cid>指定IDメッセージに紐づくCIDの添付ファイル取得
/messages/<id>.source指定IDメッセージのデータ
1)
変更したい場合には起動オプションで行う
2)
ちなみにportは51080
development/mailcatcher.txt · 最終更新: 2023/08/20 21:14 by hayashi