Noo*_*one 155 email bash terminal
我知道有很多方法可以从Linux/MacOS的终端发送电子邮件,但我似乎无法找到有关如何做到这一点的正确文档.
基本上我需要它为我的bash脚本,每当文件发生更改时通知我.
ear*_*las 132
echo "this is the body" | mail -s "this is the subject" "to@address"
Run Code Online (Sandbox Code Playgroud)
gad*_*tmo 114
进入终端并输入man mail
帮助.
您需要设置SMTP
:
http://hints.macworld.com/article.php?story=20081217161612647
也可以看看:
http://www.mactricksandtips.com/2008/09/send-mail-over-your-network.html
例如:
mail -s "hello" "example@example.com" <<EOF
hello
world
EOF
Run Code Online (Sandbox Code Playgroud)
这将发送一封example@example.com
包含主题hello
和消息的电子邮件
你好
世界
JRF*_*son 41
如果您只需要一个主题行(如在警报消息中),只需执行以下操作:
mailx -s "This is all she wrote" < /dev/null "myself@myaddress"
Run Code Online (Sandbox Code Playgroud)
Mia*_*Kim 18
如果要在Linux上附加文件
echo 'mail content' | mailx -s 'email subject' -a attachment.txt username@stackoverflow.com
Run Code Online (Sandbox Code Playgroud)
Ali*_*ich 15
可能最简单的方法是使用curl
此方法,无需安装任何其他软件包,可以直接在请求中对其进行配置。
这是使用gmail smtp服务器的示例:
curl --url 'smtps://smtp.gmail.com:465' --ssl-reqd \
--mail-from 'from-email@gmail.com' \
--mail-rcpt 'to-email@gmail.com' \
--user 'from-email@gmail.com:YourPassword' \
-T <(echo -e 'From: from-email@gmail.com\nTo: to-email@gmail.com\nSubject: Curl Test\n\nHello')
Run Code Online (Sandbox Code Playgroud)
Pra*_*ghe 10
在你的mac os或linux os终端上输入这段代码
mail -s (subject) (receiversEmailAddress) <<< "how are you?"
Run Code Online (Sandbox Code Playgroud)
举个例子试试这个
mail -s "hi" abc@example.com <<< "how are you?"<br>
Run Code Online (Sandbox Code Playgroud)
对于 SMTP 主机和 Gmail,我喜欢使用 Swaks -> https://easyengine.io/tutorials/mail/swaks-smtp-test-tool/
在 Mac 上:
brew install swaks
swaks --to user@example.com --server smtp.example.com
归档时间: |
|
查看次数: |
317388 次 |
最近记录: |