JavaMail message - removing 2 last characters

Hi!
Have you encountered the problem that the last 2 characters were removed from your message?
I'm using javamail 1.3
Thanks
rzvika2Asked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed, with points refunded (100)

Computer101
E-E Admin
0
 
TimYatesCommented:
No.  Can you post your code?
0
 
rzvika2Author Commented:
I'ts a regular and simple code, not something special,
actually, when I send it to one address the text is ok, but when I send it to another, it remove the last two chars.
If I send to the problematic email address a mail from yahoo, for example, it gets the message in the right way.
The code is something similar to this:

          Message msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          InternetAddress[] address = {new InternetAddress(args[0])};
          msg.setRecipients(Message.RecipientType.TO, address);
          msg.setSubject("JavaMail APIs Test");
          msg.setSentDate(new Date());
          // If the desired charset is known, you can use
          // setText(text, charset)
          msg.setText(msgText);
          
          Transport.send(msg);
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
CEHJCommented:
What *are* the last two characters? They may be chars not supported by the default charset
0
 
rzvika2Author Commented:
they are regular chars (in my last test, it was 'xt')
0
 
TimYatesCommented:
Is it always the same address that it fails on?

>          msg.setText(msgText);

what is "msgText"?

Tim
0
 
DrWarezzCommented:
Perhaps add two extra characters to the string :P lol
[r.D]
0
 
rzvika2Author Commented:
Yes, it is always the same address(es) (the same domain)
The message text is:
Text line1
Text line2

but what I get in the second line is
Text lin
0
 
CEHJCommented:
Are you sure it's not some 'budget' provider truncating your message out of 'economy'?
0
 
CEHJCommented:
Substitute a different String and see if it gets truncated at the same offset ;-)
0
 
rzvika2Author Commented:
Yes, DrWarezz, I've thought of that, but try all the ways before work arounds... ;-)
0
 
rzvika2Author Commented:
yes, always truncated by two chars, as I've specified in the question...
0
 
CEHJCommented:
>>yes, always truncated by two chars, as I've specified in the question...

In that case, i'll stick to my guess above as to why ;-)
0
 
rzvika2Author Commented:
CEHJ, when I send this email from another mail acount (and not from my javacode) it works fine.
0
 
DrWarezzCommented:
Have you tried using another SMTP server?
0
 
CEHJCommented:
>>CEHJ, when I send this email from another mail acount (and not from my javacode) it works fine.

Hmm. That's weird. How are you setting 'msgText' and what's in it?
0
 
rzvika2Author Commented:
no, but again, if I send the same message to 2 different emails, and only in one of them I get the message truncated, why should it be the server problem?
0
 
rzvika2Author Commented:
setText("Text - line1\nText - line2");
0
 
CEHJCommented:
You've got me stumped ;-) Try telnetting in and see what happens when you do it manually
0
 
TimYatesCommented:
Isn't there some standard where mails must end with a CR/LF?

Like when you telnet into port 25, the last line has to end with a CR/LF

Sounds to me like the mail server that fails is being a bit heavy handed with its treatment of the specification...

So as a solution, do as DrWarezz says, and just append "\n\r" to the end of any email you send...
0
 
CEHJCommented:
>>Isn't there some standard where mails must end with a CR/LF?

No, they must end with a dot on a line on its own. This probably has nothing to do with the problem though ;-)
0
 
rzvika2Author Commented:
Actually, when I append two spaces, it's ok.
0
 
TimYatesCommented:
> No, they must end with a dot on a line on its own. This probably has nothing to do with the problem though ;-)

Yeah, but the line of text before it would have \n\r on it ;-)
0
 
CEHJCommented:
Yes. Are we any nearer to explaining this mystery?
0
 
DrWarezzCommented:
Let's just blame someone, and close it :P lol
0
 
rzvika2Author Commented:
LOL
Just don't blame me ;-)
0
 
DrWarezzCommented:
lol - Who else? :P

Anyways, let's be serious now: I would put it down to being a stupid server problem.. Have you found that appending those two spaces fixes it? If so, then that's probably as close to fixing it as you're going to get  lol (atleast in my eyes).

Best of luck,
[r.D]
0
 
rzvika2Author Commented:
Yes, appending two spaces solves it.
Thank you all for such a good spirit!
Have fun!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.