Posted By:
sriram_GK
Posted On:
Saturday, September 29, 2001 04:45 AM
What is mail.host? Does that represent the senders hostname or recepients host?. I tried giving host as "mail.yahoo.com" and "mail.transport.protocol" as "smtp" and from id as "myid@yahoo.com" and to as "toid@xxx.com". When i run the jsp i get "Attribute mail.yahoo.com has no value" "Internal server error".. Please give a solution and explanation about the "mail.host". I appreciate an early answer as i need it urgently. String host = "mail.yahoo.com"; String to = request.getParameter("to"); String from = request.getParameter("from"); String subject = request.getParameter("subject"); Stri
More>>
What is mail.host? Does that represent the senders hostname or recepients host?. I tried giving host as "mail.yahoo.com" and "mail.transport.protocol" as "smtp" and from id as "myid@yahoo.com" and to as "toid@xxx.com". When i run the jsp i get "Attribute mail.yahoo.com has no value" "Internal server error"..
Please give a solution and explanation about the "mail.host". I appreciate an early answer as i need it urgently.
String host = "mail.yahoo.com";
String to = request.getParameter("to");
String from = request.getParameter("from");
String subject = request.getParameter("subject");
String messageText = request.getParameter("body");
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session mailSession = Session.getDefaultInstance(props);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
msg.setForm(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
Transport.send(msg);
out.println("Mail was sent to " + to);
out.println("Mail from " + from);
out.println("Using Host" + host +".");
Sriram
<<Less