Linux的sendmail命令怎么使用

小億
241
2023-07-13 12:28:52

sendmail是一個(gè)用于發(fā)送郵件的命令行工具,常用于Linux系統(tǒng)。下面是sendmail命令的用法:

  1. 發(fā)送簡(jiǎn)單的文本郵件:
echo "This is the body of the email" | sendmail recipient@example.com

這個(gè)命令會(huì)將文本"This is the body of the email"作為郵件正文發(fā)送給recipient@example.com。

  1. 發(fā)送帶有主題和發(fā)件人的郵件:
echo "This is the body of the email" | sendmail -s "Subject of the email" -f sender@example.com recipient@example.com

這個(gè)命令會(huì)將文本"This is the body of the email"作為郵件正文發(fā)送給recipient@example.com,同時(shí)指定郵件主題為"Subject of the email",發(fā)件人為sender@example.com。

  1. 發(fā)送帶有附件的郵件:
(echo "This is the body of the email"; uuencode attachment.txt attachment.txt) | sendmail -s "Subject of the email" -f sender@example.com recipient@example.com

這個(gè)命令會(huì)將文本"This is the body of the email"作為郵件正文發(fā)送給recipient@example.com,同時(shí)指定郵件主題為"Subject of the email",發(fā)件人為sender@example.com,并且附加了名為attachment.txt的附件。

  1. 從文件中讀取郵件內(nèi)容:
sendmail -t < email.txt

這個(gè)命令會(huì)從名為email.txt的文件中讀取郵件內(nèi)容,并發(fā)送。

以上是sendmail命令的一些常用用法,你可以根據(jù)自己的需求進(jìn)行調(diào)整和擴(kuò)展。

0