2

我正在尝试让我的家庭网络上的系统通过电子邮件发送图像(.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 和各种网络邮件界面中尝试过,结果相同)。有没有更好的方法实际上有效?

更新:只是为了好玩,我运行了这个:

uuencode -m snapshot.png snapshot.png > coded.txt

解码后,我得到了一个乱七八糟的,看不见的烂摊子。所以问题一定出在uuencoding上。

4

7 回答 7

2

在我以前的工作中,该mailx程序有一个内置的附件选项-a

来自http://linux.die.net/man/1/mailx

-一份文件

将给定的文件附加到消息中。

那么你就不必担心这些uuencode东西了。我相信您也可以添加多个-a选项来发送多个附件。

不确定此选项出现的版本(我的新工作的服务器没有它)。

于 2014-01-08T10:24:42.117 回答
1

在ubuntu上,我能够使用附件成功发送邮件

uuncode input_file1.jpg attachment1.jpg >tempfile
uuncode input_file2.jpg attachment2.jpg >>tempfile
cat tempfile | mailx -s "subject" <email>
于 2015-01-13T16:11:41.600 回答
1

我遇到了同样的问题,并通过切换到发送 mime 类型的 sendmail 来解决。

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 管道。

于 2015-06-26T07:32:03.697 回答
0

你只需要去掉“-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

希望能帮助到你。

于 2014-12-02T12:59:46.767 回答
0

阅读: https: //support.microsoft.com/en-us/kb/2590107

您应该使用 mimencode。

Mimencode 旨在替代 uuencode 用于邮件和新闻用途。原因很简单:uuencode 在许多情况和方式下都不能很好地工作。特别是,uuencode 使用的字符不能在所有邮件网关(特别是 ASCII <-> EBCDIC 网关)之间很好地转换。此外,uuencode 不是标准的——有几种变体,以不同且不兼容的方式对事物进行编码和解码,没有“标准”作为实现的基础。最后,uuencode 在管道中通常不能很好地工作,尽管已经修改了一些变体来做到这一点。Mimencode 实现了为 MIME 定义的编码作为 uuencode 替换,并且对于电子邮件使用应该更加健壮。

于 2015-05-13T02:27:23.690 回答
0

uuencode /pth/to/atch.jpg sendasname.jpg | mailx -s "主题" mail@mail.com

应该没问题 - 在 solaris 中定期使用它。

省去 -m 开关就是所有需要发生的事情。

于 2016-03-24T19:27:52.453 回答
-1

怎么样

(uuencode -m snapshot.png snapshot.png) | mailx -r "sending@myremoteserver.net" -s "Snapshot" -S smtp=smtp.myremoteserver.net me@myremoteserver.net
于 2013-12-31T19:17:28.113 回答