I'm trying to get a system on my home network to send an image (.png) via email. The closest I have gotten is this:
uuencode -m snapshot.png snapshot.png | mailx -r "[email protected]" -s "Snapshot" -S smtp=smtp.myremoteserver.net [email protected]
Which gets the mail to me, but the output leaves a bit to be desired...
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/
====
The trouble is, I HAVE to send through smtp.myremoteserver.net. But the image file isn't getting decoded by my mail client (I've tried in Thunderbird and in various webmail interfaces, same result). Is there a better way that actually works?
Update: Just for the fun of it, I ran this:
uuencode -m snapshot.png snapshot.png > coded.txt
And upon decoding it, I got a scrambled, unviewable mess. So the problem must be with the uuencoding.
At my old job, the mailx
program had an attachment option built in -a
.
From http://linux.die.net/man/1/mailx:
-a file
Attach the given file to the message.
Then you don't have to worry about the uuencode
stuff. I believe you can add multiple -a
options to send multiple attachments as well.
Not sure which version this option appeared though (the servers at my new job don't have it).