[英]Sending email attachment using uuencode and mailx
我正在尝试在家庭网络上安装一个系统,通过电子邮件发送图像(.png)。 我得到的最接近的是:
uuencode -m snapshot.png snapshot.png | mailx -r "sending@myremoteserver.net" -s "Snapshot" -S smtp=smtp.myremoteserver.net me@myremoteserver.net
哪个收到邮件给我,但输出有点不尽如人意......
begin-base64 755 snapshot.png
AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8A
AAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA
AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA
(well, you get the idea...)
AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8A
AAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA
AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/
====
麻烦的是,我必须通过smtp.myremoteserver.net发送。 但是我的邮件客户端没有解码图像文件(我在Thunderbird和各种webmail界面中尝试过,结果相同)。 有没有更好的实际工作方式?
更新:为了它的乐趣,我跑了这个:
uuencode -m snapshot.png snapshot.png > coded.txt
解码后,我得到了一个混乱的,无法看到的混乱。 所以问题必须是uuencoding。
在我以前的工作中, mailx
程序有一个内置于-a
的附件选项。
来自http://linux.die.net/man/1/mailx :
-一份文件
将给定文件附加到邮件中。
然后你不必担心uuencode
东西。 我相信你也可以添加多个-a
选项来发送多个附件。
不知道这个选项出现在哪个版本(我新工作的服务器没有它)。
在ubuntu上,我能够使用附件成功发送带附件的邮件
uuncode input_file1.jpg attachment1.jpg >tempfile
uuncode input_file2.jpg attachment2.jpg >>tempfile
cat tempfile | mailx -s "subject" <email>
我有同样的问题,并通过切换到sendmail修复,sendmail发送mime类型。
mimencode {file} | /usr/sbin/sendmail -t -oi -f {email@domain}
我没有生产中的mimencode所以我使用的openssl看起来相同:
/usr/bin/openssl base64 -e < {file} | /usr/sbin/sendmail -t -oi -f {email@domain}
如果你有更多的收件人或主题,你可以在管道的开头输入,并在最后添加mimencode输出,例如,
To: {email1} {email2}
Cc: {email3}
Subject: some subject
Mime-Version:1.0
Content-Type: text/plain
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename={filename}
{mimencode output here}
您可以将所有这些输出到文件,然后cat到sendmail管道。
你只需要摆脱“-m”选项。 它适用于Solaris 10作为发件人,outlook / lotus_notes作为邮件客户端。
使用“-m”表示“begin-base64 ...”,没有“-m”表示正常附件。
尝试:
uuencode snapshot.png snapshot.png | mailx -r "sending@myremoteserver.net" -s "Snapshot" -S smtp=smtp.myremoteserver.net me@myremoteserver.net
希望能帮助到你。
阅读本文: https : //support.microsoft.com/en-us/kb/2590107
你应该使用mimencode。
Mimencode旨在替代邮件和新闻使用的uuencode。 原因很简单:uuencode在许多情况和方式下都不能很好地工作。 特别是,uuencode使用的字符在所有邮件网关(特别是ASCII < - > EBCDIC网关)中都不能很好地转换。 此外,uuencode不是标准的 - 有几种变体浮动,以不同和不兼容的方式编码和解码事物,没有基于实现的“标准”。 最后,uuencode在管道中通常不能很好地工作,尽管已经修改了一些变体。 Mimencode实现了为MIME定义为uuencode替换的编码,并且对于电子邮件使用应该更加健壮。
uuencode /pth/to/atch.jpg sendasname.jpg | mailx -s“Subject”mail@mail.com
应该做得很好 - 经常在solaris中使用它。
省略-m开关是所有需要发生的事情。
怎么样
(uuencode -m snapshot.png snapshot.png) | mailx -r "sending@myremoteserver.net" -s "Snapshot" -S smtp=smtp.myremoteserver.net me@myremoteserver.net
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.