tags:

views:

649

answers:

7

I am sending newsletters from a Java server and one of the hyperlinks is arriving missing a period, rendering it useless:

Please print your <a href=3D"http://xxxxxxx.xxx.xx.edu=
au//newsletter2/3/InnovExpoInviteVIP.pdf"> VIP invitation</a> for future re=
ference and check the Innovation Expo website <a href=3D"http://xxxxxxx.xx=
xx.xx.edu.au/2008/"> xxxxxxx.xxxx.xx.edu.au</a> for updates.

In the example above the period was lost between edu and au on the first hyperlink.

We have determined that the mail body is being line wrapped and the wrapping splits the line at the period, and that it is illegal to start a line with a period in an SMTP email:

http://tools.ietf.org/html/rfc2821#section-4.5.2

My question is this - what settings should I be using to ensure that the wrapping is period friendly and/or not performed in the first place?

UPDATE: After a lot of testing and debugging it turned out that our code was fine - the client's Linux server had shipped with a very old Java version and the old Mail classes were still in one of the lib folders and getting picked up in preference to ours. JDK prior to 1.2 have this bug.

+3  A: 

From an SMTP perspective, you can start a line with a period but you have to send two periods instead. If the SMTP client you're using doesn't do this, you may encounter the problem you describe.

It might be worth trying an IP sniffer to see where the problem really is. There are likely at least two separate SMTP transactions involved in sending that email.

Greg Hewgill
A: 

I am not sure, but it looks a bit as if your email is getting encoded. 0x3D is the hexadecimal character 61, which is the equals character ('=').

What classes/libary are you using to send the emails? Check the settings regarding encoding.

jmagica
A: 

Are you setting the Mime type to "text/html"? You should have something like this:

BodyPart bp = new MimeBodyPart();
bp.setContent(message,"text/html");
Jataro
+1  A: 

Make sure all your content is RFC2045 friendly by virtue of quoted-printable. Use the MimeUtility class in a method like this.


    private String mimeEncode (String input)
    {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    OutputStream out;
    try
    {
        out = MimeUtility.encode( bOut, "quoted-printable" );
        out.write( input.getBytes( ) );
        out.flush( );
        out.close( );
        bOut.close( );
    } catch (MessagingException e)
    {
        log.error( "Encoding error occured:",e );
        return input;
    } catch (IOException e)
    {
        log.error( "Encoding error occured:",e );
        return input;
    }

    return bOut.toString( );
    }


Yiannis
A: 

I am having a similar problem, but using ASP.NET 2.0. Per application logs, the link in the email is correct 'http://www.3rdmilclassrooms.com/' however then the email is received by the client the link is missing a period 'http://www3rdmilclassrooms.com'

I have done all I can to prove that the email is being sent with the correct link. My suspicion is that it is the email client or spam filter software that is modifying the hyperlink. Is it possible that an email spam filtering software would do that?

A: 

I had a similar problem sending email programmatically over to a yahoo account. They would get one very long line of text and add their own linebreaks in the HTML email, thinking that that wouldnt cause a problem, but of course it would.

the trick was not to try to send such a long line. Because HTML emails don't care about linebreaks, you should add your own every few blocks, or just before the offending line, to ensure that your URL doesn't get split at a period like that.

I had to change my ASP VB from

var html;
html = "Blah Blah Blah Blah ";
html = html & " More Text Here....";

to

var html;
html = "Blah Blah Blah Blah " & VbCrLf;
html = html & " More Text Here....";

And that's all it took to clean up the output as was being processed on their end.

Karl
This won't be of much help if the text is being encoded with quoted-printable, as in the sample provided in the question. Quoted-printable has a limit of 76 chars per line.
liggett78
A: 

As Greg pointed out, the problem is with your SMTP client, which does not do dot-stuffing (doubling the leading dot).

It appears that the e-mail is being encoded in quoted-printable. Switching to base64 (I assume you can do it with the current java mime implementation) will fix the problem.

liggett78