Hi,
I want to send emails from JSP. So I created a java class that I call. This is theagment that does not work:
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.company.lt");
props.put("mail.smtp.auth", "false");
Session emlSession = Session.getInstance(props, null);
Message msg = new MimeMessage(emlSession);
msg.setFrom(new InternetAddress("my@email.lt"));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("my@email.lt", false));
msg.setSubject("subject");
msg.setText("text");
SMTPTransport t = (SMTPTransport)emlSession.getTransport("smtp");
t.connect();
t.sendMessage(msg, msg.getAllRecipients());
t.close();
System.out.println("\nMail was sent successfully.");
I getException:
javax.mail.MessagingException: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=us-ascii
Could you help me?
maybe there is another solution to sent email from JSP?
Thanks in advance.
ASKER
I followed the steps in http://docs.cs.byu.edu/docs/javamail_api/:
I downloaded mail.jar, activation.jar. I added them in ...tomcat/webapps/mail/WEB
Now my code looks like this:
Properties props = new Properties();
props.setProperty("mail.sm
props.setProperty("mail.su
props.setProperty("mail.fr
props.setProperty("mail.to
props.setProperty("mail.de
javax.mail.Session emailSession = javax.mail.Session.getInst
MimeMessage msg = new MimeMessage(emailSession);
InternetAddress from = new InternetAddress(props.getP
InternetAddress to = new InternetAddress(props.getP
msg.setFrom(from);
msg.setRecipient(Message.R
msg.setSubject(props.getPr
msg.setContent("text", "text/plain");
javax.mail.Transport.send(
And the error is:
javax.mail.MessagingExcept
Also what is mailcap? where can I appned this line?
text/plain;; x-java-content-handler=com