如何使用unix脚本发送邮件 [英] how to send a mail with a message in unix script
本文介绍了如何使用unix脚本发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在.ksh中写一个脚本,并且要求发送带有消息的邮件。
目前在我的脚本中使用此命令:
mailx -s找不到文件abc@def.com
此命令可帮助我拥有主题和收件人名称。
我的问题是如何与它一起写邮件。因为每次运行脚本时,它会暂停,并要求我输入消息,然后执行,我想预先包含消息,以便脚本不会暂停。
解决方案
echo' mail -s'主题行在这里'email@provider.com
New to unix and learning the talk and walk of it. I am writing a script in .ksh and have a requirement of sending a mail with a message. Currently using this command in my script:
mailx -s"File not found" abc@def.com
This command helps me having a subject and the recipient name. My question is how can I write a message along with it. Cause every time i run the script it pauses and asks me to enter the message and then executes, I want to pre-include the message so the script would not pause in between.
解决方案
echo 'Message body goes here' | mail -s 'subject line goes here' email@provider.com
这篇关于如何使用unix脚本发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文