import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import com.sun.mail.smtp.SMTPSSLTransport;
public class SendMail {
private Session session;
private String adresse, absender, body, ausgabe, betreff;
public void setSession(Session param) {
this.session = param;
}
public void setAdresse(String param) {
this.adresse = param;
}
public void setAbsender(String param) {
this.absender = param;
}
public void setBody(String param) {
this.body = param;
}
public void setBetreff(String param) {
this.betreff = param;
}
public String getAusgabe() {
try {
MimeMessage message = new MimeMessage(session);
DataHandler mime = new DataHandler(body, "text/html");
message.setDataHandler(mime);
InternetAddress from = new InternetAddress(absender);
message.setFrom(from);
InternetAddress rcpt = new InternetAddress(adresse);
message.addRecipient(Message.RecipientType.TO, rcpt);
message.setSubject(betreff);
ausgabe = "Ihre Zugangsdaten wuerden an ";
Transport transport = new SMTPSSLTransport(session, new URLName("smtp", "mail.gmx.net",
465, null, "xxx", "xxx"));
transport.connect();
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
catch(MessagingException msgexcep) {
ausgabe = msgexcep.getMessage();
}
return ausgabe;
}
}