problems with email sending
kevmaster May 20, 2008 4:35 PMHello, i have got a little problem, but i dont know to solve it.
I have got a register form, which store new users. Every new user get an email with a generated password, after that the generated password is hashed with md5.
Problem is, how to send the email with the plain password.
Now its only working after hashing, but this isnt useful.
Code which works:
... @Out(required=false) private String plainPassword; public String createUser(User user) { plainPassword = randomPassword();// generate random password plainPassword = hashPassword.hash(plainPassword); //md5 hash of generated password user.setPassword(plainPassword);//set password to user this.sendRegistrationEmail(); //send mail em.persist(user); facesMessages.add("user added"); return "home"; } ...
email which works:
<m:message xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://jboss.com/products/seam/mail" xmlns:h="http://java.sun.com/jsf/html"> <m:from name="my program" address="test@domain.com" /> <m:to name="#{user.forename} #{user.surname}">#{user.email}</m:to> <m:subject>your password</m:subject> <m:body> <p><h:outputText value="Hello #{user.forename} #{user.surname}" />,</p> <p>here u get your password.</p> <p><i>#{user.password}</i></p> </m:body> </m:message>
This works fine, but the user should get the plain password, but it doesnt work:
... @Out(required=false) private String plainPassword; public String createUser(User user) { plainPassword = randomPassword();// generate random password this.sendRegistrationEmail(); //send mail plainPassword = hashPassword.hash(plainPassword); //md5 hash of generated password user.setPassword(plainPassword);//set password to user this.sendRegistrationEmail(); //send mail em.persist(user); facesMessages.add("user added"); return "home"; } ...
email:
<m:message xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://jboss.com/products/seam/mail" xmlns:h="http://java.sun.com/jsf/html"> <m:from name="my program" address="test@domain.com" /> <m:to name="#{user.forename} #{user.surname}">#{user.email}</m:to> <m:subject>your password</m:subject> <m:body> <p><h:outputText value="Hello #{user.forename} #{user.surname}" />,</p> <p>here u get your password.</p> <p><i>#{plainPassword}</i></p> </m:body> </m:message>
Why it dont work.
Help please.
Thx Kev