This content has been marked as final. Show 6 replies
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.