Using mail from the command line: if you want to send true attachments (that show up in graphical mail clients as attachments), you need something like "mutt" or CleanCode Email.
If it's just arbitrary text or a file you want to send, and don't care about it looking like a real attachment, you can use ordinary "mail" ("mailx" on some Unixes) at the command line. However, that's NOT a mime attachment - it's just your file mixed in to the mail message. However, some mail clients will see it and treat it as a real attachment, so this may be "good enough":
mailx -s "This is it" [email protected] <
more text" | mailx somebody somebodyelse [email protected]
You can use uuencode to send a binary file the same way, and some mail clients may even display that as they would a "real" attachment.
However: that's NOT an attachment. Every time somebody asks this question on the newsgroup, someone is sure to insist that it is, but a simple visual examination of actual messages should show them their error. The confusion is, of course, that some mail clients will act as though the uuencoded text were a proper attachment. That's fine if the people you are sending to use one of those clients, but if there is any chance they do not, be safe: use Mutt.
You can also use mpack to put a file into MIME format.
If you found something useful today, please consider a small donation.
Got something to add? Send me email.