Search code examples
jspemailshort

short version of jsp mail?


I'm searching for an "one-liner" for mailing within jsp. I just wanna send the values of 5 parameters to the webmasters mail-address. Any ideas for a short solution?


Solution

  • More like a 6-liner, but you can use commons-email:

    import org.apache.commons.mail.SimpleEmail;
    ...
    
      SimpleEmail email = new SimpleEmail();
      email.setHostName("mail.myserver.com");
      email.addTo("jdoe@somewhere.org", "John Doe");
      email.setFrom("me@apache.org", "Me");
      email.setSubject("Test message");
      email.setMsg("This is a simple test of commons-email");
      email.send();