Hi, AppModule.java ============ public static void bind(ServiceBinder binder) { binder.bind(EmailService.class); }
services/EmailService.java =================== import org.apache.commons.mail.EmailException; public interface EmailService { public void sendForgottenUsernameAndPassword(String emailTo, String password) throws EmailException; } services/EmailServiceImpl.java ====================== public class EmailServiceImpl implements EmailService { private SmtpService smtpService; private Configuration configuration; public EmailServiceImpl(SmtpService smtpService, ConfigurationService configurationService) { this.smtpService = smtpService; Resource configResource = new ClasspathResource("identity-server.properties"); this.configuration = configurationService.getConfiguration(configResource); } public void sendForgottenUsernameAndPassword(String emailTo, String password) throws EmailException { SimpleEmail email = new SimpleEmail(); email.setCharset("utf8"); String subject = configuration.getString("email-forgotten-password-subject"); email.setSubject(subject); email.addTo(emailTo); String emailFrom = configuration.getString("email-confirm-account-from"); email.setFrom(emailFrom); String message = "Plain text message."; email.setMsg(message); smtpService.sendEmail(email); } } and then in your page class: @Inject private EmailService emailService; void onSuccess() { // send email with newly generated password for the user with given email String rawPassword = RandomStringUtils.randomAlphanumeric(6); String email = someEmail; try { emailService.sendForgottenUsernameAndPassword(email, rawPassword); } catch (EmailException e) { logger.warn("Sending email have failed."); } } Hope that helps. The above example also uses ConfigurationService ( http://www.chenillekit.org/chenillekit-core/configuration.html) to read properties from file. Cheers, Borut 2009/6/18 newtonik <newto...@gmail.com> > > Can anyone give me an example on how to use this > http://www.chenillekit.org/chenillekit-mail/SmtpService.html mailer . I am > new to Tapestry and I have been trying some of their components. I decided > to try the mailer today but I don't seem to know how to get it to work. I > don't seem to know how to Inject the Service into my pages. > > Can someone point me in the right direction? > > How about what people use to mail? Does everyone basically use the Apache > Commons EMail? > -- > View this message in context: > http://www.nabble.com/ChenilleKit-Mail----How-to-Use--or-Any-Mailer--tp24085676p24085676.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >