1754321 Members
2753 Online
108813 Solutions
New Discussion юеВ

corrupted attachments

 
renarios
Trusted Contributor

corrupted attachments

Hi All,

Every Friday automatically emails with attachments are sent from on of our HP-UX machines using mailx from a shell script. Some of these mails go directly to our internal our exchange server and some of them are sent cross-domain over the internet. Internally sent emails are received successfully, but one of our customers receives the email with a corrupted attachment. I have tested by sending the mail to my private mail server and the attachment is OK. Has anyone met the same issue? Can I change a parameter with mailx or should the customer change setting on their exchange server?
Here is a code fragment:
## Begin code

file="HUBBA.DAT"
filealias="HUBBA_$(date '+%m%d').DAT"
purpose="leerlingen-administratie"

filepath="/tmp"
DATFILE="${filepath}/${file}"
EXTENSION="${file#*.}"
BASE_NAME="${file%.${EXTENSION}}"
subject="blah blah"
message="blah blah"

# Check if datfile exists
f_check_datfile
f_retval

# Send the E-mail message...
mailx -r ${RETURN_ADDRESS} -s "${subject}" ${target_address} < $(ux2dos ${DATFILE} | uuencode ${filealias})
${notification}
Hallo ${firstname}. ${sirname},

${message}
${notification}
Bij dit bericht is het bestand ${filealias} als bijlage toegevoegd.

===================================================
Dit is een automatisch gegenereerde email.
Als u deze email ten onrechte heeft ontvangen,
meldt u dit a.u.b. aan ${RETURN_ADDRESS}
===================================================
EOF
## End code
Nothing is more successfull as failure
14 REPLIES 14
harry d brown jr
Honored Contributor

Re: corrupted attachments

change this line:

mailx -r ${RETURN_ADDRESS} -s "${subject}" ${target_address} <
TO

mailx -m -r ${RETURN_ADDRESS} -s "${subject}" ${target_address} <
The "-m" tells mailx that the message contains mime encoded items.

I tested your original code sniplet and I ALSO received a "garbled" message:
----------------------------------------------
begin 666 =dah.txt
M:&]S=&YA;65A#0I(4B!D979E;&]P;65N="P@1&%T82!297!OM=F5L;W!M96YT+"!C2!S='5F9BP@;6]R92!C2!S='5F9@T*,<&ED('-T=69F#0H:
`
end
notification
Hallo firstname. sirname,
----------------------------------------------

But once I added the "-m" option the item came in as an attachment.

live free or die
harry d brown jr
Live Free or Die
spex
Honored Contributor

Re: corrupted attachments

renarios,

If you continue to have problems, you might want to give SEP's famous mailfile attachment script a shot:

http://www.hpux.ws/mailfile2

PCS
renarios
Trusted Contributor

Re: corrupted attachments

Hi Harry,

You are right! In the original code I do use the -m option. With -m the email text is OK, but in the attachment some line feeds just dissapear.
If I don't use the "-m" even the text in the email looks Russian to me.
I personally think that it hat to do with setting on the customers' Exchange settings, but I'm not sure.

All suggestions are welcome!

Cheers,

Renarios
Nothing is more successfull as failure
renarios
Trusted Contributor

Re: corrupted attachments

Hi spex,

Thanks for the hint. I will give it a go!

Cheers,

Renarios
Nothing is more successfull as failure
harry d brown jr
Honored Contributor

Re: corrupted attachments

What is EXTENSION equal to? Is it ".dat" ? If so, then the user might have a different "default" application attempting to open the attachment. I don't have any default application assigned to open ".dat" files, thus I'm prompted to choose an application to open the attachment.

if this is just a text file, then try changing the EXTENSION to ".txt"

live free or die
harry d brown jr
Live Free or Die
renarios
Trusted Contributor

Re: corrupted attachments

Hi Harry,

Originally the extension is (excuse me) .cum (for cumulative file). Because of all firewalls and proxies I alias it to .DAT instead ;^)
We tested by mailing from UNIX to customer;
customer forwards mail including attachment;
They try to load file into forms application (I think it uses SQL*loader on background), which failes.
When I open the attachment with Ultraedit, some line feeds and spaces (just four or five times in fourhudred lines) are dissapeared. It beats me what causes it.

Cheers,

Renarios
Nothing is more successfull as failure
spex
Honored Contributor

Re: corrupted attachments

Renarios,

You may want to run the file through 'ux2dos' before attaching it so that LF's get translated to CR's & LF's. If you don't have 'ux2dos', 'awk' also works:

awk '{print $0"\r"}' < file_unix > file_dos

PCS
renarios
Trusted Contributor

Re: corrupted attachments

Hi spex,

I do use ux2dos :
$(ux2dos ${DATFILE} | uuencode ${filealias})
, but thanx for the hint.

More and more I begin to think are to be found in exchange. Is anyone feeling exchange goeroe today?
Nothing is more successfull as failure
spex
Honored Contributor

Re: corrupted attachments

Renarios,

I guess I missed that ;-).

I wonder if sending the file as a binary will make a difference. Try compressing or gziping it before you attach it. Of course, the danger here is if the message gets alterted en route, the archive will be corrupt.

PCS