Need help sending attachment via mailx

Hello, I am new to the Unix thing, and I am having trouble sending attachments via shell client putty through mailx.

The command I use is

$ mailx -s "Subject" user@blah.com < attachment.txt

but everytime I do that it would say Cannot open attachment.txt

I have the file save to my computer in the directory designated by putty shell client, but I can seem to get the file to open, please help.

What directory is the directory designated by putty shell client?

What directory were you in when you ran the mailx command?

I'm using the Putty portable client, so it's on a USB drive. The both the File and the Program is located in F:\PuTTYPortable folder which is where I would run the program.

I don't think the (remote) server has access to your (local) F:\PuTTYPortable directory.

You could do this with uuencode:

uuencode file.txt file.txt |mailx -s "enter subject here" emal@emal.com

If you don't mind using Perl, you can download and install Perl MIME::LITE and use that.
The link includes some sample code. Last time I looked the module had not changed
in awhile. But the code works and it is easy to use.

MIME::Lite - search.cpan.org