tags:

views:

512

answers:

2

I'm attempting to deliver the same message whether its over FTP or email, but the saved file keeps coming out as different sizes. The textual content of the message is the same, but the nonprintable characters must be accounting for the different size!

When transferring the text file over FTP (in Binary mode to prevent FTP translation of EOL characters), the delivered file size is 7660 bytes.

When I deliver the message over email (sent with smtp, retrieved with POP3), the delivered message size (when dumped straight into a fresh file) is 8043 bytes. The email is sent as a plain text email, and the message comprises the entire email body. This is a size difference of 383 bytes, and the linecount is 385 lines, leading me to think the two are related... but try as I might, I can't get the same message over email!

I've tried several combinations of stripping carriage returns and linefeeds on the email message data, to no avail!

Do MIME messages have a different way of dealing with linefeeds?

A: 

Not a solution, but it would of course be a good idea to compare the two messages byte-for-byte, to determine exactly what the differences are. I agree based on what you've said that it sounds like a line-ending problem, but it would be better to be sure.

Also, if you're really using FTP to transfer messages (that sounds kind of odd, but okay), you might want to investigate the differences to your results from switching between FTP's binary vs its ascii/text modes.

unwind
Yup, I've tried switching the FTP code to use ascii instead, and it didn't make any difference. Most probably because its going from a windows server to a windows machine, thus the EOL character remains the same. I'd like to compare them byte-to-byte. What's a good tool to do that on windows?
Gabriel
+1  A: 

During SMTP, you're supposed to end each line with CR LF. If your original email ends each line with a newline, after it's transferred, the mailers might have converted each newline to a CR LF, which would add one extra byte for each line.

On the other hand, it might be coincidence. Have you looked to see if the mail programs at either end added extra header lines, like From lines?

codebunny
I'm not using the headers of the emails at all, I'm just getting the mail, extracting the body of the message, and saving that to a file, so additional headers isn't a problem
Gabriel