This content has been marked as final. Show 6 replies
JavaMail imposes no limit.
Mail servers will sometimes impose a limit on total message size.
Thanks for replying.
Can JavaMail dectect such server settings?
The server might declare the maximum message size it accepts using the SMTP SIZE extension.
You can query for the value using:
That's the total size of a message. Note that not all servers will return this information, even
though they might enforce a limit.
Computing the actual size of a message can be expensive.
The simplest approach is something like this:
CountingOutputStream cos = new CountingOutputStream();
int size = cos.getSize();
CRLFOutputStream is in the JavaMail download bundle in the demo directory.
You have to write CountingOutputStream by subclassing OutputStream and counting the
number of bytes written without doing anything with them.
Thanks, however it looks like you instruct me to get the total size of a message, right? What I want is to get the maximum size allowed.
I told you how to do both - find the maximum size the server allows (SMTP SIZE parameter)
and compute the size of a message you have, e.g., to see if it's less than the maximum size
allowed by the server.
Thank you very much! I got it :-)