2019-06-27 14:33:23 681浏览
今天千锋扣丁学堂Linux培训老师给大家分享一篇关于如何用Linux命令行发电子邮件的详细介绍,首先Linux可以用多种方式通过命令行发送电子邮件。有一些方法十分简单,有一些相对会复杂一些,不过仍旧提供了很多有用的特性。选择哪一种方式取决于你想要什么——向同事快速发送消息,还是向一批人群发带有附件的更复杂的信息。接下来看一看几种可行方案。
$ echo "Reminder: Leaving at 4 PM today" | mail -s "early departure" myboss
$ mail -s "Reminder:Leaving early" myboss < reason4leaving
$ echo "leaving now" | sendmail recip
$ echo "Subject: leaving now" | sendmail recip
Subject: Requested lyrics I would just like to say that, in my opinion, longer hair and other flamboyant affectations of appearance are nothing more ...
$ sendmail recip < lyrics
$ sendmail -v recip@emailsite.com < lyrics
$ echo "Please check last night's backups" | mutt -s "backup check" recip
$ mutt -s "Agenda" recip < agenda
$ mutt -s "Agenda" recip -a agenda -a speakers < msg
$ echo "" | mutt -s "Agenda" recip -a agenda -a speakers
$ mutt -s "Minutes from last meeting" recip@somesite.com -c myboss < mins
$ telnet emailsite.org 25 Trying 192.168.0.12... Connected to emailsite. Escape character is '^]'. 220 localhost ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Wed, 12 Jun 2019 16:32:13 -0400; (No UCE/UBE) logging access from: mysite(OK)-mysite [192.168.0.12] EHLO mysite.org <== introduce yourself 250-localhost Hello mysite [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP MAIL FROM: me@mysite.org <== 指定发件人 250 2.1.0 shs@mysite.org... Sender ok RCPT TO: recip <== 指定收件人 250 2.1.5 recip... Recipient ok DATA <== 邮件内容开始 354 Enter mail, end with "." on a line by itself This is a test message. Please deliver it for me. . <== 内容结束 250 2.0.0 x5CKWDds029287 Message accepted for delivery quit <== 结束交互
$ for recip in `cat recips` do mutt -s "Minutes from May meeting" $recip < May_minutes done
【关注微信公众号获取更多学习资料】 【扫码进入HTML5前端开发VIP免费公开课】