0

In the signup process of Spring Lemon, I'm trying to send the verification email. I've put messages_en.properties and messages_fr.properties in my resourcesfolder. Here is the relevant content of messages_en.properties

com.naturalprogrammer.spring.verifyEmail: Hi,<br/><br/>Your email id at XYZ is unverified. Please click the link below to get verified:<br/><br/>{0}<br/><br/>

But when I look at the logs, it sends the mail without replacing the {0} by the verifyLink.

I looked at the code and figured out that this portion of LemonService is the isse :

            // send the mail
        mailSender.send(user.getEmail(),
            LemonUtil.getMessage("com.naturalprogrammer.spring.verifySubject"),
            LemonUtil.getMessage(
                "com.naturalprogrammer.spring.verifyEmail", verifyLink));

But the actual work is being done by this code in LemonUtil.java :

                /**
 * Gets a message from messages.properties
 * 
 * @param messageKey    the key of the message
 * @param args          any arguments
 */
public static String getMessage(String messageKey, Object... args) {

    // http://stackoverflow.com/questions/10792551/how-to-obtain-a-current-user-locale-from-spring-without-passing-it-as-a-paramete
    return messageSource.getMessage(messageKey, args,
            LocaleContextHolder.getLocale());
}

I managed to solve it somehow by deleting the {0} in the .properties, and by adding the link myself like this :

            // send the mail
        mailSender.send(user.getEmail(),
            LemonUtil.getMessage("com.naturalprogrammer.spring.verifySubject"),
            LemonUtil.getMessage(
                "com.naturalprogrammer.spring.verifyEmail", verifyLink) + verifyLink);

I think the getMessage method of org.springframework.context.MessageSource is not working properly. My question is : what could prevent messageSource from working ?

Sanjay
  • 8,755
  • 7
  • 46
  • 62
mozexty
  • 44
  • 1
  • 6
  • Try putting ` ` (whitespace) around `{0}` ... Putting it between HTML tags could be problematic. – M. Deinum Jun 13 '16 at 05:55
  • I tried that, no success – mozexty Jun 13 '16 at 10:12
  • To get some answers, seems like you'd need to try it out with a minimal project, just with a single controller class with `MessageSource` injected, without involving Spring Lemon, and then re-post the question crisply. – Sanjay Jun 14 '16 at 11:09

0 Answers0