Take the 2-minute tour ×

I am new to JavaMail API and I have got a problem. My sending is done throw Google API, my code is:

final String username = from;
    final String password = passwd;

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");

    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);

    try {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipient));
        message.setContent(content, "text/html");


    } catch (MessagingException e) {
        throw new RuntimeException(e);

I want to assign a link to a web page to the content variable (the body of the email). It would be a verification email to verify the validity of the user, so it would be like mywebsite.com/user/2341341341 (the numbers are generated). I have tried a lot of combinations with - http://mywebsite.com/user/2341341341 - http://wwww.mywebsite.com/user/2341341341 and so on The link appears blue and underlined in some cases, in others it is plain text (in yahoo mail, in gmail works) and in others the Mail.app in MacOS renders it as x-msg://234/mywebsite.com/user/2341341341 (it looks like a link but it doesn't redirects me anywhere), in others gmail puts the email in spam...

I would like a cross platform solution or with click here or simply http://mywebsite.com/user/2341341341 to be a link that a user could click

Any help would be appreciated.

share|improve this question
add comment

1 Answer

Are you adding the link to your html content using the proper html tags?

There's a lot you can't control about how mail readers behave. You can't control what they consider to be spam. You can't control whether they allow users to follow links in messages. All you can do is format your html text and link correctly and make sure it isn't spam.

share|improve this answer
add comment

Your Answer


