Quantcast
Channel: プログラム の個人的なメモ
Viewing all articles
Browse latest Browse all 860

【Linux】 ダミーSMTPサーバ構築

$
0
0

はじめに

http://blogs.yahoo.co.jp/dk521123/36230453.html
で、Windows環境にて、ダミーSMTPサーバとして、smtp4dev を利用した。
今回は、Linux環境で、ダミーSMTPサーバを立てる

種類

[1] FakeSMTP(Java製)
[2] MailCatcher(Ruby製)

# 他にも、DebuggingServer(Python製)など色々あるらしいが...

[1] FakeSMTP

 * Java Ver1.6以上

設定手順

[1] 以下のサイトの「Download」からモジュール「fakeSMTP-latest.zip」を落としてくる
http://nilhcem.github.io/FakeSMTP/index.html
[2] [1]のモジュール「fakeSMTP-latest.zip」を解凍する
 => 解凍すると「fakeSMTP-2.0.jar」が出てくる
# Windowsの場合、JARファイルをダブルクリックするだけ
[3] コマンドで「java -jar fakeSMTP-2.0.jar 【オプション】」で起動する

[Options]
  -s : 自動立ち上げモード
  -b : GUIでの立ち上げをオフ
  -p : ポート番号の指定(-p xxxx) / デフォルトは、port 25
  -a : アドレス
  -o : 特定の場所にメールを格納(-o directory)
  -m : メモリモード(メールを保存しない場合に使用) 

 [例]
 java -jar fakeSMTP-2.0.jar -s -b -p 2525 -a 127.0.0.1

公式サイト

http://nilhcem.github.io/FakeSMTP/index.html

参考文献

http://www.moongift.jp/2013/05/20130507-3/
http://propg.ee-mall.info/it/%E3%83%A1%E3%83%BC%E3%83%AB%E9%80%81%E4%BF%A1%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%81%AE%E7%A2%BA%E8%AA%8D%E7%94%A8%E3%81%AB%EF%BC%81%EF%BC%81-%E3%80%8Cfakesmtp%E3%80%8D/

[2] MailCatcher

設定手順

[1] 以下のコマンドを入力

sudo yum update
sudo yum groupinstall "Development Tools"
sudo yum install ruby-devel ruby19-devel sqlite-devel openssl openssl-devel
sudo yum install rubygems

# インストール
gem install mailcatcher

# 起動
mailcatcher

[2] ブラウザで以下のURLにアクセスする
[[http://localhost:1080/]]

補足:mailcatcherのオプション

# ヘルプ
mailcatcher --help
# ポート変更
mailcatcher --smtp-port 20025 --http-port 20080
構文
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
    -b, --browse                     Open web browser
    -v, --verbose                    Be more verbose
    -h, --help                       Display this help information

【任意設定】Apacheとの連携

 * なお、Apacheの設定は、以下の関連記事を参照のこと。
http://blogs.yahoo.co.jp/dk521123/36072244.html
[1] /etc/httpd/conf.d 配下に、以下のMailCatcher.confを新規作成する
/etc/httpd/conf.d/MailCatcher.conf
ProxyPass /mailcatcher http://localhost:1080

【任意設定】Mailcatcherの自動起動

 * systemd を使って、Mailcatcherを自動起動させる

# systemd については、以下の関連記事を参照のこと。
http://blogs.yahoo.co.jp/dk521123/36255225.html
 [1] /etc/systemd/system 配下に、以下のMailCatcher.service を新規作成
 [2] 以下のコマンドを入力し、サービスの自動起動ONにし、OS再起動。

 systemctl enable MailCatcher.service
 reboot
/etc/systemd/system/MailCatcher.service
[Unit]
 Description=Mailcatcher Service

[Service]
 Type=simple
 ExecStart=/usr/local/bin/mailcatcher --foreground --smtp-port 20025 --http-port 20080

[Install]
 WantedBy=multi-user.target


関連記事

Linux(仮想環境) を構築する ~CentOS編~

http://blogs.yahoo.co.jp/dk521123/36252928.html

Java で、 Email を送るには... ~ JavaMail / テキストメール編 ~

http://blogs.yahoo.co.jp/dk521123/36230453.html

CentOS7でのサービス(デーモン) ~ systemd ~

http://blogs.yahoo.co.jp/dk521123/36255225.html

Viewing all articles
Browse latest Browse all 860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>