0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Postfix をローカルで使う

Last updated at Posted at 2023-06-28

こちらと同じことを、クロムブックの linux で行いました。
ローカル環境下で使えるメールサーバをセットアップする Postfix編

使った環境

$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

インストール

postfix のインストール

sudo apt install postfix

サーバーの選択は、LOCAL を選びます。

テストに使う telnet のインストール

sudo apt install telnet

環境の設定

/etc/postfix/main.cf
(省略)
#
home_mailbox = Maildir/

Postfix の再起動

sudo systemctl restart postfix

ユーザーの作成

sudo adduser -uid 1220 holiday001

テスト

telnet localhost 25

holiday001@penguin.lxd にメールを送ります。

$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 penguin.lxd ESMTP Postfix (Debian/GNU)
mail from:holiday001@penguin.lxd
250 2.1.0 Ok
rcpt to:holiday001@penguin.lxd
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Hello
.
250 2.0.0 Ok: queued as B83604FF3F
quit
221 2.0.0 Bye
Connection closed by foreign host.

メールが届いていることを確認

sudo ls -l /home/holiday001/Maildir/new
$ sudo cat /home/holiday001/Maildir/new/1687912721.V32I4ff40M231351.penguin
Return-Path: <holiday001@penguin.lxd>
X-Original-To: holiday001@penguin.lxd
Delivered-To: holiday001@penguin.lxd
Received: from localhost (localhost [IPv6:::1])
        by penguin.lxd (Postfix) with SMTP id B83604FF3F
        for <holiday001@penguin.lxd>; Wed, 28 Jun 2023 09:38:15 +0900 (JST)
Message-Id: <20230628003825.B83604FF3F@penguin.lxd>
Date: Wed, 28 Jun 2023 09:38:15 +0900 (JST)
From: holiday001@penguin.lxd

Hello

mail コマンドで確認

ユーザーの切り替え

su holiday001
$ mail
Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/holiday001": 1 message 1 unread
>U  1 holiday001@pengui  Wed Jun 28 07:10   15/490   
& p
Message 1:
From holiday001@penguin.lxd  Wed Jun 28 07:10:31 2023
X-Original-To: holiday001@penguin.lxd
Date: Wed, 28 Jun 2023 07:10:17 +0900 (JST)
From: holiday001@penguin.lxd

Hello
Good Morning

& q
Saved 1 message in /home/holiday001/mbox
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?