markdown 从Linux命令行发送电子邮件(postfix或netcat)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 从Linux命令行发送电子邮件(postfix或netcat)相关的知识,希望对你有一定的参考价值。

 * Send a blank test message with a subject to an email address:

    `mail -s "Subject" user@example.com < /dev/null`
    
    (you can substitute /dev/null with a file, or pipe, to populate the body. It must end with a period on a line by itself.)

 * Send a blank email with an attachment:

    `mail -a somefile -s "Subject" user@example.com < /dev/null`

 * Use `netcat` or `telnet`
 
```
mjl@tesla> nc localhost 25
220 tesla.local ESMTP Postfix
HELO gmail.com
250 tesla.local
MAIL FROM: mike@tesla.local
250 2.1.0 Ok
RCPT TO: user@example.com
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: test message

hello from tesla
.
250 2.0.0 Ok: queued as 7D91946
QUIT
221 2.0.0 Bye
mjl@tesla>
```

The [SMTP commands](https://www.samlogic.net/articles/smtp-commands-reference.htm) may be lower-case, I spelled them in uppercase here for clarity.   There is no SMTP command for *Subject*, use the DATA command and add whatever headers you want, separate from the body with a blank line.

以上是关于markdown 从Linux命令行发送电子邮件(postfix或netcat)的主要内容,如果未能解决你的问题,请参考以下文章