Sei*_*iti 59 unix linux email shell
我在运行Linux shell的服务器上.我需要将一个简单的文件邮寄给收件人.怎么做,优先使用mail命令?
更新:得到一个很好的解决方案,使用mutt代替:
$ echo | mutt -a syslogs.tar.gz admin@domain.org
Run Code Online (Sandbox Code Playgroud)
Jon*_*Jon 49
使用uuencode的示例:
uuencode surfing.jpeg surfing.jpeg | mail sylvia@home.com
Run Code Online (Sandbox Code Playgroud)
和参考文章:
http://www.shelldorado.com/articles/mailattachments.html
Sei*_*iti 20
$ echo | mutt -a syslogs.tar.gz admin@domain.org
Run Code Online (Sandbox Code Playgroud)
但它使用mutt,而不是mail(或mailx).
mat*_*tiu 20
mail在我试过的每个版本的现代Linux上都可以做到.不需要其他软件:
matiu@matiu-laptop:~$ mail -a doc.jpg someone@somewhere.com
Subject: testing
This is a test
EOT
Run Code Online (Sandbox Code Playgroud)
完成输入后按ctrl + d.
Dav*_*low 12
mailx也可能有所帮助.来自mailx手册页:
-a file
Attach the given file to the message.
Run Code Online (Sandbox Code Playgroud)
很简单吧?
njs*_*jsf 11
我的答案除了邮件之外还需要base64,但是一些uuencode版本也可以用-m做base64,或者你可以忘记mime并使用普通的uuencode输出......
FROM=me@mydomain.com
TO=someone@mydomain.com
SUBJECT="Auto emailed"
MIME="application/x-gzip" # Adjust this to the proper mime-type of file
FILE=somefile.tar.gz
ENCODING=base64
boundary="---my-unlikely-text-for-mime-boundary---$$--"
(cat <<EOF
From: $FROM
To: $REPORT_DEST
Subject: $SUBJECT
Date: $(date +"%a, %b %e %Y %T %z")
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
Content-Disposition: inline
--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
This email has attached the file
--$boundary
Content-Type: $MIME;name="$FILE"
Content-Disposition: attachment;filename="$FILE"
Content-Transfer-Encoding: $ENCODING
EOF
base64 $FILE
echo ""
echo "--$boundary" ) | mail
Run Code Online (Sandbox Code Playgroud)
小智 7
mailx -a /path/to/file email@address
Run Code Online (Sandbox Code Playgroud)
您可能会进入交互模式(它会提示您使用"主题:",然后是空白行),输入主题,然后输入正文并点击Ctrl+ D(EOT)完成.
| 归档时间: |
|
| 查看次数: |
299550 次 |
| 最近记录: |