使用 sendmail 发送测试电子邮件的另一种方法:

printf "Subject: Put a subject here" | sendmail -vf put_your_email_here@example.com to_whoever@example.org

输出示例:

$sendmail -vt < ./mail.txt 
put_your_email_here@example.com... Connecting to [127.0.0.1] via relay...
220 example.org ESMTP Sendmail 8.14.4/8.14.4; Sat, 26 Mar 2011 20:47:21 +0800 (MYT)
>>> EHLO example.org
250-example.org Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
>>> MAIL From: SIZE=144
250 2.1.0 ... Sender ok
>>> RCPT To:
>>> DATA
250 2.1.5 ... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 p1QClLLW073679 Message accepted for delivery
put_your_email_here@example.com... Sent (p1QClLLW073679 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 example.org closing connection
Sendmail - 如何测试发送电子邮件,详细使用 Sendmail

使用 sendmail 详细测试发送电子邮件

准备一个名为“mail.txt”的文件。
这将是我们在测试发送此电子邮件时要包含的电子邮件标题和内容。
该文件的内容应如下所示:

To: put_your_email_here@example.com
Subject: Put a subject here
From: to_whoever@example.org
Of cause, here's the place to put the body

测试发送电子邮件的实际命令:

sendmail -vt < [email file above]
日期:2020-06-02 22:17:15 来源:oir作者:oir