Hello!
We want to send an email from a jsp to the Recipient (variable: youradress) from the emailadress given in our profile (variable: myadress).
There appears a error message at the command Transport.send(message).
<%@ page language="java"
import="java.util.*, javax.mail.*, javax.mail.internet.*"
%>
<%@ page language="java" import="model.User" %>
<%
model.User user = db.DBMUser.getUserById(session.getAttribute("user").toString());
String mymail = user.getEmail();
String mailadresse = request.getParameter("mailadresse");
String nachricht = request.getParameter("nachricht");
InternetAddress myadress = new InternetAddress(mymail);
InternetAddress youradress = new InternetAddress(mailadresse);
try{
Properties prop=new Properties();
prop.put("mail.smtp.host","mail.gmx.net");
Session s = Session.getDefaultInstance(prop);
//MimeMessage message = new MimeMessage(s);
Message message = new MimeMessage(s);
message.setFrom(myadress);
message.addRecipient(Message.RecipientType.TO,youradress);
message.setSubject("Einladung");
message.setText(nachricht);
message.setContent(message, "text/plain");
Transport.send(message);
out.println("Ihre E-Mail wurde erfolgreich versandt.");
}
catch(MessagingException msgexcep) {
out.println(msgexcep.getMessage());
}
%>
error message in the browser:
org.apache.jasper.JasperException: An exception occurred processing JSP page /send.jsp at line 34
31: message.addRecipient(Message.RecipientType.TO,youradress);
32: message.setSubject("Einladung zur Heimwehplattform");
33: message.setText(nachricht);
34: Transport.send(message);
35:
36: out.println("Ihre E-Mail wurde erfolgreich versandt.");
37: }