[英]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.