Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Linux / UNIX and the fly likes Sending mail with body and attachment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Sending mail with body and attachment" Watch "Sending mail with body and attachment" New topic
Author

Sending mail with body and attachment

Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
Hello All,

I am trying to send email from unix server that has body and attachment both. But I am successful in sending either body or attachment. I have done a lot of goggling on it but could not find anything. Can anyone please help me on this.





Nothing worked for me. It attches the body in garbled character in the mail itself.

Please advise something on it.

Thanks,
Patricia.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

According to the manpage of uuencode and common shell knowledge, you have to specify stdout (-) as filename if you want to pipe your output to mailx.

However, I don't know whether the part right to the pipe is right - I don't run a mailserver and get an error about a missing default user.


http://home.arcor.de/hirnstrom/bewerbung
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

The entire content of email is text from start to finish. If you were wondering how this allows attaching images, videos, viruses, and other non-text items, the answer is that uuencode converts the raw binary to a series of text characters, although this means that the MIME-encoded attachment will be somewhat bigger than the original binary data. The email format RFC also outlines the special text lines that are used to delimit attachments, so that they won't be mistaken for general email message text.

In case you were wondering why the insistence on text, it's because when the original standards were set up, a lot of the computers involved were IBM mainframes, which use EBCDIC instead of ASCII. Some of the original Internet machines had even stranger restrictions, such as 6-bit character codes. So MIME made it possible for a simple standard to work equally well for all of them. As a side benefit, you can easily test a lot of this stuff using simple telnet logins, and you can diagnose content with common text utilities instead of specialized one-of-a-kind binary applications.

You can build up the entire email, attachments and all by brute force text manipulation, but in actual practice, we cheated and used mutt as our batch mail agent.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending mail with body and attachment