SMTPサーバのテストをしたくなったのでDockerで環境を作った話。
SMTPサーバのテストをしたくなったので
ということ、ありませんか?
僕は最近試してみたいなぁと思いました。
なのでみんな大好きDockerで構築してみます。よくある動機ですね。
それで、調べてみるとDocker Hubに良さげなイメージがあったのでさくっと環境構築してみます。
なお、今回はDockerはインストール済みとしています。以下の環境で動かしています。
環境
Mac OS Catalina 10.15.7
Docker version 20.10.2
手順
1.イメージをビルドする
こちらのDocker Hubに記載されているようにすれば基本的には起動できます。
本編とは関係ないですが、よくみたら最後に更新されたのが5年前になっていますね。
$ sudo docker pull catatnight/postfix
2.コンテナを起動する
sudo docker run -p 25:25 \
-e maildomain=mail.example.com -e smtp_user=user:pwd \
--name postfix -d catatnight/postfix
これでSMTPサーバが立ち上がりました。
一応docker ps
コマンドでコンテナが起動しているかを確認します。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
********** catatnight/postfix "**/**/** '/**/**…" 3 minutes ago Up 3 minutes 0.0.0.0:25->25/tcp postfix
無事起動していますね。
3.telnetで接続する
telnetで起動したSMTPサーバに接続しましょう。
なお、今回はMac OSです。
Mac OSではtelnetはプリインストールされていないのでHomebrewを使ってインストールします。
$ brew install telnet
!! ここで以下のエラーが出ました。
Error: Permission denied @ apply2files - /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/extglob/lib/.DS_Store
Permission deniedなので権限で弾かれていますね。
調べてみるとこちらの内容が参考になりました。
僕の場合は
$ sudo chown -R ${username}:staff /usr/local/lib/node_modules
${username}は自身のMacのユーザ名に置き換えてください。
これで弾かれることはなくなったので無事インストールできます。
そして以下のコマンドで
$ telnet localhost smtp
これで以下のメッセージが出れば接続完了です。
Trying ::1...
Connected to localhost.
Escape character is '^]'.
MAIL FROM:foo@gmail.com
250 2.1.0 Ok
QUIT
221 2.0.0 Bye
Connection closed by foreign host.221 2.0.0 Bye
Connection closed by foreign host.
あとは実際にSMTPサーバとしてテストをするだけです。
止める時は上記のようにQUITコマンドを打つと終了します。
Hello!
返信削除People working in a website development company do not usually take up freelancing. This may be because of personal reasons or because the website development company that they work for, doesn’t allow them to take up freelancing jobs. Even if they try to apply for freelancing, they are always at risk as their names can show up in the freelancing websites that they work for. However, Eiliana has provided a solution for this problem. Freelancers employed under a company can take up freelance website development jobs from the Eiliana website as it provides anonymity to the freelancers. This means that they can work without their names ever coming into the show.