使用Linux Mailx发送简单的邮件正文和文件附件 [英] Sending simple message body + file attachment using Linux Mailx

查看:959
本文介绍了使用Linux Mailx发送简单的邮件正文和文件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写shell script以使用Linux Mailx发送电子邮件,该电子邮件必须包含文件附件消息正文.

I am writing a shell script to send an email using Linux Mailx, the email must contain a file attachment and a message body.

当前正在发送带有附件的电子邮件:

Currently sending an email with an attachment:

output.txt | mail -s "Daily Monitoring" james@dell.com

我希望添加一个消息正文.我应该怎么办?

I wish to add a message body. How should i?

Linux Mailx:

Linux Mailx:

mail [-eIinv] [-a header] [-b addr] [-c addr] [-s subj] to-addr

推荐答案

通常的方法是使用 用于附件,echo用于正文:

The usual way is to use uuencode for the attachments and echo for the body:

(uuencode output.txt output.txt; echo "Body of text") | mailx -s 'Subject' user@domain.com


对于Solaris和AIX,您可能需要先放置echo语句:


For Solaris and AIX, you may need to put the echo statement first:

(echo "Body of text"; uuencode output.txt output.txt) | mailx -s 'Subject' user@domain.com

这篇关于使用Linux Mailx发送简单的邮件正文和文件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆