LoginSignup
1
0

More than 1 year has passed since last update.

503 5.5.1 Error: need MAIL command

Posted at

現在さくらvpsを契約しており、メールの送受信の機能を利用したいと考え、postfixと,telnetをos内にインストールしました。設定方法などがわからなかったため以下のサイトを参考にし、設定等を行ったのですが、メールを送信しようとするとエラーになります。
少し手順が長いですが、目を通して頂いて返信して頂ければ幸いです。
自分的にはドメイン周りが怪しいと思っているのですが、、

参考URL

手順

インストール

sudo dnf install postfix

自動設定

sudo systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.

main.cfファイルの修正
変更前の「main.cf」のバックアップをとる

sudo cp -p /etc/postfix/main.cf  /etc/postfix/main.cf.20221_bk

「main.cf」の修正

sudo vi /etc/postfix/main.cf

mydomain(ドメイン)自分はtk2-209-14402.vs.sakura.ne.jp

mydomain = tk2-209-14402.vs.sakura.ne.jp

myorigin(ドメイン)

myorigin = $mydomain

inet_interfaces(ローカルホスト以外からも受け取る)

inet_interfaces = all

inet_protocols (プロトコルはIPv4のみ)#inet_protocols = allをコメントアウトしてinet_protocols = ipv4を記載、適用。

inet_protocols = all
inet_protocols = ipv4

mydestination (宛先ドメイン)自分のドメインを追加

mydestination = $myhostname, localhost.$mydomain, localhost, tk2-209-14402.vs.sakura.ne.jp←自分のドメイン

mynetworks (ネットワークは最初はローカルホストのみ)

#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
mynetworks = localhost

home_mailbox (メールボックスの形式)※コメントを外す

#home_mailbox = Maildir/
  ↓    ↓
home_mailbox = Maildir/

設定ファイル編集後postfix再起動 

sudo systemctl restart postfix
sudo systemctl status postfix
起動が正常な状態
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor pre>
   Active: active (running) since Tue 2021-06-08 22:36:47 JST; 15s ago
  Process: 24247 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCE>
  Process: 24246 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, >
  Process: 24241 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, stat>
 Main PID: 24316 (master)
    Tasks: 3 (limit: 6022)
   Memory: 26.4M
   CGroup: /system.slice/postfix.service
           ├─24316 /usr/libexec/postfix/master -w
           ├─24317 pickup -l -t unix -u
           └─24318 qmgr -l -t unix -u
Jun 08 22:36:47 tk2-209-14402.vs.sakura.ne.jp systemd[1]: Starting Postfix Mail>

Jun 08 22:36:47 tk2-209-14402.vs.sakura.ne.jp postfix/master[24316]: daemon sta>
Jun 08 22:36:47 tk2-209-14402.vs.sakura.ne.jp systemd[1]: Started Postfix Mail >
lines 1-17/17 (END)

postfixインストール後のメール送信テスト

telnetインストール

sudo dnf install telnet

テスト用ユーザーの作成(ユーザー名:mailsend),パスワード設定

sudo useradd mailsend -s /sbin/nologin
sudo passwd mailsend
Changing password for user mailsend.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

ディレクトリの書き込み付与

chmod 777 /var/spool/mail

talnetコマンドでSMTP接続のテスト

telnet localhost 25

以下の表示が出たらそのまま必要なコマンドを入力する。


Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 tk2-209-14402.vs.sakura.ne.jp ESMTP Postfix

heloコマンドで応答する
helo localhost
250 tk2-209-14402.vs.sakura.ne.jp


宛先のメールは⁠rcpt to: で入力。
エラーの出現

rcpt to: mailsend@tk2-209-14402.vs.sakura.ne.jp
503 5.5.1 Error: need MAIL command
1
0
1

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
1
0