Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't send attachment in metamail

Status
Not open for further replies.

volcano

Programmer
Aug 29, 2000
136
HK
Hello guys and gals, I have a trouble in using metamail to send attachment. Your advice to me is very much appreciated~

I am using Solaris OS now. And i have installed metamail in it. When I tar a PDF file into a tar file and then metasend it to my mailbox, it works without problem. But when I tar MORE THAN ONE PDFs into a tar file and then mail to myself again, my email becomes splitting into several mails and contain unrecognised text. Do you encounter such situation? My used MIME-type is Application/tar (i tried x-tar, zip, x-zip too..). The encoding method is Base64. Do you have any idea? Thanks in advance

Volcano
 
Annihilannic have told me to use command uuencode like below,it works well.

uuencode file.tar.gz file.tar.gz|mailx -s "attach test" foo@some.com
 
Thanks bluelake for your great help! I have tried your command and I can really receive that attachment! However I have another question about it. When I use Windows-based email client (in my case, Lotus Notes) to receive and open that attachment sent from my Solaris OS, that attachment (it's a tar file) can't be opened! I guess the attachment should undergo something like uudecode first before opening it. Do I need to do anything more to achieve my purpose?

Very touched by your speedy reply~
 
i have no idea cause i havn't use lotus, perhaps you can modify some configuration on your lotus notes...

m$'s outlook can uudecode it automatically

but you can issue the command 'uudecode file.tar.gz' to get the original binary file then manipulate it as your wish.
 
You can uuencode any type of file to attach it; it doesn't have to be .tar.gz. To attach multiple files simply use multiple uuencodes, for example:

[tt]( uucencode file1 file1 ; uuencode file2 file2 ) | mailx -s "subject" recipient@machine[/tt] Annihilannic.
 
Thanks both of you for your generous help!

I finally found the reason why my attachment sending goes wrong. The reason is the problem of mail size. As I combine many PDFs into a tar file and mail it outside, the default SPLITSIZE reaches easily. So my mail is splitted into parts. Therefore in order to send a complete email with a larger attachment, just set the env. variable SPLITSIZE to be larger or specify the option "-S" in metasend command (i refer to the MAN page of metasend)

But now I have another question...it seems that metasend does not allowme to rename the attachment...the attachment name seems to be randomly generated. Is there any other way to rename attachment?

For the UUENCODE solution, I think it's fine. However, I am not sure, are the Windows email client programs unable to UUDECODE those EEENCODED attachments? My Lotus Notes can't open my UUENCODED tar file...

I haven't tried mpack. Will this do better?
 
Is that because it doesn't know what to do with a .tar file though? If it shows up as an attachment on your email (instead of the uuencoded text) then it has worked.

uuencoded attachments work fine with most common email clients. Annihilannic.
 
Hello, thanks for your reply. I know again why my UUENCODE did not succeed. The story is i tar all my PDFs into a tar file. When I use UUENCODE command, I name the tar file as xxx.zip and then send it to my mailbox. Then my lotus notes mail client won't be able to open this file; but if I name the tar file as xxx.tar and send out, my lotus notes can open that tar file by winzip successfully.
 
If the attachment's showing up as a tar file, you should install WinZip. It understands tar files and integrates with most emails, so it can open tar file attachments.

Hope this helps.

 
Thank you all of you!

Now I can use winzip in windows to open the attachments sent from Solaris OS. Now I have another challenge. The command :

( uucencode file1 file1 ; uuencode file2 file2 ) | mailx -s "subject" recipient@machine

is just what I need. But I can't hard-code the file names in this command. That means file1 and file2 should be variables in my script. Besides the files must be in PDF extension this time. So how can I read the directory and check if PDFs exist and then UUENCODE those PDFs without knowing their names in advance?

Thanks~
 
#!/usr/bin/ksh
for FILE in `ls *.pdf`
do
( uuencode $FILE $FILE ) | mailx -s .....
done

You will have to mess about if you want them all sent in the one email - i.e. construct your command line on the fly as a string and call it at the end of the procedure.

JB
 
Simply move the brackets:

[tt]#!/usr/bin/ksh
( for FILE in `ls *.pdf`
do
uuencode $FILE $FILE
done ) | mailx -s .....[/tt]


Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top