public String sendForm() {
String MAIL_SERVER = "mail.********.de";
String DAEMON_EMAIL_ADR = "*****";
String DAEMON_EMAIL_PW = "****";
String CONTENT_TYPE = "text/plain";
String[] CONTENT_LANGUAGE = {"de"};
String emailTo = "****@******.de";
String emailFrom="ti@mo.de";
String subject="Kontaktformular";
Properties props = new Properties();
Session session = Session.getDefaultInstance(props);
session.setDebug(false);
MimeMessage msg = new MimeMessage(session);
InternetAddress adressFrom=null;
InternetAddress adressTo=null;
try {
adressFrom = new InternetAddress(emailFrom);
adressTo = new InternetAddress(emailTo);
} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String contactLastname = (String)parameterHashMap.get("contactLastname");
String contactFirstname = (String)parameterHashMap.get("contactFirstname");
String contactStreet = (String)parameterHashMap.get("contactStreet");
String contactPostalCode = (String)parameterHashMap.get("contactPostalCode");
String contactCity = (String)parameterHashMap.get("contactCity");
String contactPhone = (String)parameterHashMap.get("contactPhone");
String contactMobile = (String)parameterHashMap.get("contactMobile");
String contactEMail = (String)parameterHashMap.get("contactEMail");
String contactICQ = (String)parameterHashMap.get("contactICQ");
String contactComment = (String)parameterHashMap.get("contactComment");
String content = "Dies ist generierte Nachricht!\n";
content+="\n";
content+="Die nachfolgende Nachricht wurde im Kontakt-Formular des*************\n";
content+="hinterlegt. Hier die Kontaktdaten der Person:\n";
content+="\n";
content+="";
content+="Name, Vorname: " + contactLastname + "," + contactFirstname + "(" + contactEMail + ")\n";
content+="Strasse: " + contactStreet + "\n";
content+="PLZ, Ort: " + contactPostalCode + " " + contactCity + "\n";
content+="Telefon: " + contactPhone + "\n";
content+="Empfänger: " + emailTo + "\n";
content+="\n";
content+="--------------------------------------------------------------------------------\n";
content+="\n";
content+=contactComment;
try {
msg.setFrom(adressFrom);
msg.setRecipient(Message.RecipientType.TO, adressTo);
msg.setSubject(subject);
msg.setContent(content,CONTENT_TYPE);
msg.setContentLanguage(CONTENT_LANGUAGE);
} catch (MessagingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
javax.mail.Transport transport = session.getTransport("smtp");
transport.connect(MAIL_SERVER,DAEMON_EMAIL_ADR,DAEMON_EMAIL_PW);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
} catch (NoSuchProviderException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (MessagingException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
return content;
}