My code is like this:
String smepserver = Request.getparameter ("Txtserver");
String mailTo = Request.getparameter ("Txtto");
String Frommail = Request.getparameter ("Txtfrom");
String subject = Request.getparameter ("Txtsubject");
String message = Request.getparameter ("Txtmessage");
try{
Properties Props = new properties ();
Props.put ("Mail.transport.protocol", "SMTP");
Props.put ("Mail.smtp.host", smepserver);
Props.put ("Mail.smtp.port", "stmp.163.com");
Session MailMessage = Session.getinstance (props,null);
Message msg = new MimeMessage (mailmessage);
Msg.setfrom (New InternetAddress (Frommail));
Msg.setrecipients (Message.recipienttype.to,internetaddress.parse (mailTo));
Msg.setsentdate (New Date ());
Msg.setsubject (subject);
Msg.settext (message);
Transport transport = Mailmessage.gettransport ("SMTP");
Transport.send (msg);
Msg.writeto (System.out);
Out.print ("Send success!!") ");
}catch (Exception e) {
Out.print ("Send failed!!") ");
System.out.println (e);
}
On the mail server enter: Stmp.163.com submit, the message cannot be sent, the error is:
Javax.mail.MessagingException:Unknown SMTP host:stmp.163.com;
Nested exception is:
Java.net.unknownhostexception:stmp.163.com