無法在 cmd 行上使用郵件傳送電子郵件,但可以使用 telnet smtp 指令

無法在 cmd 行上使用郵件傳送電子郵件,但可以使用 telnet smtp 指令

在 ubuntu 系統上,我安裝了 postfix 並在 /etc/postfix/main.cf 設定檔中設定了 relayhost 和 mynetworks 。

我現在可以遠端登入該伺服器上的連接埠 25,並透過發出 SMTP 命令發送電子郵件。我對 Gmail 帳戶進行了測試,並正常收到了電子郵件。

但在同一台 Linux 主機上,我安裝了郵件(apt-get mailutils)並執行了以下命令:

mail -s "test email" myname@gmailcom

輸入了一些訊息文字和 Ctrl-D,沒有看到任何錯誤,但收件人從未收到訊息。

我是否必須以某種方式在郵件配置中設定 smtp 伺服器?我應該看到某種隊列中等待發送的訊息嗎?

有關如何解決的任何提示嗎?

更多資訊:

我的 /etc/mailname 設定檔包含字串:mail.mydomain.com 且我的 Linux 機器沒有設定域(它只是一個測試系統)。我應該將其更改為僅郵件嗎? (郵件是盒子的主機名稱)。

我找到了一種郵件語法,它允許您指定適合我的寄件者:

mail -s "message 5" -a "From: [email protected]" [email protected]

但我更願意修復,所以我不需要這樣做。

這是我透過互動使用郵件看到的錯誤:

Return-Path: <>
X-Original-To: johnny@mail
Delivered-To: johnny@mail
Received: by mydomain.com (Postfix)
        id BC328647FF; Sun,  6 Jul 2014 18:04:51 +0100 (BST)
Date: Sun,  6 Jul 2014 18:04:51 +0100 (BST)
From: [email protected] (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: johnny@mail
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary="3EEA5647FE.1404666291/mydomain.com"
Message-Id: <[email protected]>

This is a MIME-encapsulated message.

--3EEA5647FE.1404666291/mydomain.com
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii

This is the mail system at host mydomain.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<[email protected]>: host post.demon.co.uk[91.221.168.151] said: 504 5.5.2
    <johnny@mail>: Sender address rejected: need fully-qualified address (in
    reply to RCPT TO command)

--3EEA5647FE.1404666291/mydomain.com
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; mydomain.com
X-Postfix-Queue-ID: 3EEA5647FE
X-Postfix-Sender: rfc822; johnny@mail
Arrival-Date: Sun,  6 Jul 2014 18:04:46 +0100 (BST)
Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.5.2
Remote-MTA: dns; post.demon.co.uk
Diagnostic-Code: smtp; 504 5.5.2 <johnny@mail>: Sender address rejected: need
    fully-qualified address

--3EEA5647FE.1404666291/mydomain.com
Content-Description: Undelivered Message
Content-Type: message/rfc822

Return-Path: <johnny@mail>
Received: by mydomain.com (Postfix, from userid 1000)
        id 3EEA5647FE; Sun,  6 Jul 2014 18:04:46 +0100 (BST)
Subject: msg 10
To: <[email protected]>
X-Mailer: mail (GNU Mailutils 2.99.98)
Message-Id: <[email protected]>
Date: Sun,  6 Jul 2014 18:04:46 +0100 (BST)
From: johnny@mail (John Hammond)
test message

--3EEA5647FE.1404666291/mydomain.com--

答案1

若要查看郵件是否可能位於佇列中,請mailq在命令列上使用,或檢查目錄的內容/var/spool/mail。 Postfix 也應該記錄到- 您可以打開另一個 shell 會話,並在其他 shell 會話中/var/log/maillog運行時尾隨此文件- 使用mailtail -f /var/log/maillog

相關內容