LoginSignup
2
2

More than 5 years have passed since last update.

Postfix で外部からメールを送信

Last updated at Posted at 2018-05-14

Postfix で外部からメールを送ろうとして、次のようなエラーが出た時の対応です。

An error occurred while sending mail. The mail server responded:  
4.7.1 <scott@example.co.jp>: Relay access denied.
 Please check the message recipient "scott@example.co.jp" and try again.

1) まず、telnet でメールサーバーにアクセスできることを確認します。

$ telnet example.co.jp 25
Trying 133.130.98.29...
Connected to example.co.jp.
Escape character is '^]'.
220 mail.example.co.jp ESMTP Postfix
helo example.co.jp
250 mail.example.co.jp
quit
221 2.0.0 Bye
Connection closed by foreign host.

telnet で、rcpt to: コマンドを入力するとエラーが出ます。

2) /etc/postfix/main.cf を編集します。
IP アドレスが 153.140.201.204 とすると、次のパラメーターを入れます。

mynetworks = 168.100.189.0/28, 127.0.0.0/8, 153.140.201.204

そして、postfix を再起動します。

sudo systemctl restart postfix

送信できることを、telnet で確認してから、Thunderbird などのクライアントで確認します。

telnet での確認方法です。

$ telnet example.co.jp 25
Trying 133.130.98.29...
Connected to example.co.jp.
Escape character is '^]'.
220 mail.example.co.jp ESMTP Postfix
helo example.co.jp
250 mail.example.co.jp
mail from: scott@example.co.jp
250 2.1.0 Ok
rcpt to: tiger@gmail.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Test Postfix
From: scott@example.co.jp
Test
Good Afternoon
.
250 2.0.0 Ok: queued as E1894260C7B
quit
221 2.0.0 Bye
Connection closed by foreign host.
2
2
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
2
2