# email attachment always corrupt in FreeBSD8.2/amd64



## Bogi (May 10, 2011)

Hi all,

I've been using FreeBSD/i386 since 2004 for all my servers. Recently I got two identical servers and installed FreeBSD 8.2/i386 for one server
and FreeBSD 8.2/amd64 for the other.

I started using the amd64 one for my mail server:
- Sendmail 8.14.4 as the MTA
- popd-2.2.2 as the POP3
- NOCC and Openwebmail as the MUA

Everything works fine, I can send and receive email with an attachment. But there's one problem: if the attachment is bigger than around 60KB
it always corrupts every time it was downloaded/viewed (whether I used NOCC, Openwebmail, Microsoft Outlook, Mozilla Thunderbird, it always gives the same result: File is corrupt!)

I startws checking whether there's a missing configuration in Sendmail, popd, NOCC, Openwebmail, but no effect. Then finally I tried to move my mail file (/var/mail/bogi) to the other server (the one that use FreeBSD 8.2/i386) and everything works fine (I am able to download the same attachment).

Was there something I missed in FreeBSD8.2/amd64?

My servers are: IBM Server Blade x3250.

Thanks in advance.


----------



## wblock@ (May 10, 2011)

Use md5(1) to verify the file is the same on both 32-bit and 64-bit systems.  I'd guess a word size bug at 64K in the program that's trying to extract or view the attachment, but there aren't enough details to really say.  What kind of attachment, in what format?


----------



## Bogi (May 11, 2011)

thanks for the reply,

even the size of the attachment file is different from the original (smaller)
so I don't have to use md5 to check both file (original and attachment).

and it failed for every kind of attachment, doc, docx, xls, xlsx, rar, zip, 
even a text file is corrupt (as long as the size is bigger than 60KB).

oh.. I forgot 1 detail, when I send an email to somewhere else (ex. gmail and yahoo)
the attachment are fine, it only corrupt when I have the email in my mail server.


----------



## wblock@ (May 11, 2011)

Specifics might narrow it down.  How much smaller is the bad file than the same good file?  Did the missing part come off the beginning or end of the file, or somewhere in between?  Is the attachment okay if you access it through a local login on the server rather than through POP?


----------



## Bogi (May 11, 2011)

For example, in 1 attachment, the original file size is 189KB, but when it become an attachment in amd64 server, the MUA said the file size is 208KB (and it said it's a corrupt file.

But when I transfer the mail file (/var/mail/bogi) to i386 server the MUA said the file size is 189KB (and no corrupt file).


----------



## Bogi (May 11, 2011)

The problem is, the comparison between the original and the attachment is never the same and the different byte is sometime in between, and sometime in the end of file.

Sorry, what do you mean with "local login"? is it using "mail" command line? I've tried, but how can I save the attachment using "mail" command line? I can only save the email using "mail" command line.


----------



## wblock@ (May 11, 2011)

Compare file sizes in bytes so you know exactly how many bytes have been lost.

By local login, I mean using an MUA running on the FreeBSD system, like mail/alpine or mail/mutt.


----------



## OH (May 11, 2011)

I remember popd thrashing my attachments. Switched to dovecot and never looked back.


----------



## Bogi (May 11, 2011)

I think the problem is on how the amd64 and i386 version read the file. Perhaps you can download my mailbox at: http://118.97.188.243/bogi. Using this file, I can read the attachment on FreeBSD 8.2/i386 server and got "file corrupt" on FreeBSD 8.2/amd64 server.

I'll try to use mutt to check.

Thanks.


----------



## Bogi (May 11, 2011)

Thanks guys, I just used mutt to open the email in FreeBSD 8.2/i386 server, save the attachment, and it WORKS fine (I can open the file without error).

So I suspect the problem is in the popd (/usr/ports/mail/popd) which, maybe, has a bug in 64-bit version of FreeBSD.

Now I will try to use Dovecot (mail/dovecot) as suggested by OH and will give back my report to you guys.


----------



## AndyUKG (May 11, 2011)

Hi,

Just to save you some time and trouble, you want mail/dovecot2, mail/dovecot is the older version so best to get the current one installed from day one.

ta Andy.


----------



## Bogi (May 21, 2011)

Thank you all

I've installed Dovecot to replace POPD, and everything works perfect in my FreeBSD 8.2/amd64 machine. Fast mail retrieval, no more corrupt attachment, and I can even play with the secure mode in pop3 and imap.

Thank you.


----------

