LoginSignup
0
0

Azure で postfix のインストールを試す

Last updated at Posted at 2023-04-08

「Azure で最初のクラウドサーバを無料枠で作成する」
https://qiita.com/nanbuwks/items/120858191caf3b0a3f1c

で作成した、Ubuntu22.04サーバに、postfix をインストールしてローカルでの動作を確認してみます。

環境

サーバ Microsoft Azure 上の Ubuntu 22.04

今回は、サーバは Azure 上の Virtual Server を使っていますが、特に Azure の機能は使っていません。

postfix

メール関連のソフトウェアの種類として、MUA/MTA/MRAがあります。

一般にメールクライアントソフトと言われているものは MUA、
メールサーバと言われているもののうち、SMTPサーバとして馴染みがあるのが MTA、
メールサーバと言われているもののうち、POP3サーバとして馴染みがあるのが MRA となります。

今回は、まず MTA としての postfix をインストールします。

インストール

$ sudo apt install postfix

以下の設定では、今回は「Internet Site」を選びます
image.png

以下はそのまま
image.png

インストールが終わりましたが、Azureの送信ポートが開いていないので、外部にメールを送ることはできません。
image.png

メールを送ってみる

外部にメールを送ることはできませんが、サーバ内部のユーザ同士でメールを送ってみます。
今 ssh で azureuser としてログオンしています。
「Azure/Ubuntu/Apache2 で PHP と VirtulaHost を設定する」
https://qiita.com/nanbuwks/items/d3a1a148e597f5c5df1c
で追加した example ユーザにメールを送ってみます。

$ echo "Hello postfix" | sendmail example

メールを送りましたが、メールソフトとして Thunderbird や gmail
などを使って読むことはできません。サーバー内部でメールを読むために、メールユーティリティをインストールします。

$ sudo apt install mailutils

example ユーザになってメールを読んでみましょう

azureuser@test-azure-gen:~$ su - example
Password: 
example@test-azure-gen:~$ mail
"/var/mail/example": 1 message 1 new
>N   1 Ubuntu             Sat Apr  8 06:06  11/635   
?

メールが届いているのがわかります。メールリストとして1通しかありませんが、それを指定して読んでみます。

? 1
Return-Path: <azureuser@test-azure-gen.d5vkxbztwwse1dua0e2ybepgyg.phxx.internal.cloudapp.net>
X-Original-To: example
Delivered-To: example@test-azure-gen.d5vkxbztwwse1dua0e2ybepgyg.phxx.internal.cloudapp.net
Received: by test-azure-gen.d5vkxbztwwse1dua0e2ybepgyg.phxx.internal.cloudapp.net (Postfix, from userid 1000)
	id 0C1B03F9A1; Sat,  8 Apr 2023 06:06:41 +0000 (UTC)
Message-Id: <20230408060641.0C1B03F9A1@test-azure-gen.d5vkxbztwwse1dua0e2ybepgyg.phxx.internal.cloudapp.net>
Date: Sat,  8 Apr 2023 06:06:41 +0000 (UTC)
From: Ubuntu <azureuser@test-azure-gen.d5vkxbztwwse1dua0e2ybepgyg.phxx.internal.cloudapp.net>

Hello postfix

? 

メールを読むことができました。
q でMUAを抜けます。

? q
Saved 1 message in /home/example/mbox
Held 0 messages in /var/mail/example
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0