使用sendmail发送邮件失败,会收到一封邮件。比如随便编写一个错误的邮箱地址,域名不存在,肯定是不会发送成功,那么就可以看看,发生了什么?
使用 sendmail 发送邮件
echo "test" | sendmail youxiangmi-not-exit.com
You have new mail in /var/mail/root
可以看到有行错误提示 You have new mail in /var/mail/root
这个错误提示,不是马上就出现了,一般要等一分钟左右。等你再次点击按键的时候,就会出现。
查看邮件的内容,这里使用mail命令
Return-Path: <>
X-Original-To: root@youxiangmi.com
Delivered-To: root@youxiangmi.com
Received: by youxiangmi.com (Postfix)
id 5D1B06042B; Sat, 29 Jan 2022 01:40:23 +0800 (HKT)
Date: Sat, 29 Jan 2022 01:40:23 +0800 (HKT)
From: MAILER-DAEMON@youxiangmi.com (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: root@youxiangmi.com
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="57B5660400.1643391623/youxiangmi.com"
Content-Transfer-Encoding: 8bit
Message-Id: <20220128174023.5D1B06042B@youxiangmi.com>
This is a MIME-encapsulated message.
--57B5660400.1643391623/youxiangmi.com
Content-Description: Notification
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
This is the mail system at host youxiangmi.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
<youxiangmi-not-exit.com@youxiangmi.com> (expanded from
<youxiangmi-not-exit.com>): unknown user: "youxiangmi-not-exit.com"
--57B5660400.1643391623/youxiangmi.com
Content-Description: Delivery report
Content-Type: message/delivery-status
Reporting-MTA: dns; youxiangmi.com
X-Postfix-Queue-ID: 57B5660400
X-Postfix-Sender: rfc822; root@youxiangmi.com
Arrival-Date: Sat, 29 Jan 2022 01:40:23 +0800 (HKT)
Final-Recipient: rfc822; youxiangmi-not-exit.com@youxiangmi.com
Original-Recipient: rfc822;youxiangmi-not-exit.com@youxiangmi.com
Action: failed
Status: 5.1.1
Diagnostic-Code: X-Postfix; unknown user: "youxiangmi-not-exit.com"
--57B5660400.1643391623/youxiangmi.com
Content-Description: Undelivered Message
Content-Type: message/rfc822
Content-Transfer-Encoding: 8bit
Return-Path: <root@youxiangmi.com>
Received: by youxiangmi.com (Postfix, from userid 0)
id 57B5660400; Sat, 29 Jan 2022 01:40:23 +0800 (HKT)
Message-Id: <20220128174023.57B5660400@youxiangmi.com>
Date: Sat, 29 Jan 2022 01:40:23 +0800 (HKT)
From: root <root@youxiangmi.com>
test
--57B5660400.1643391623/youxiangmi.com--