JavaMail how to send mail to 163

Source: Internet
Author: User
Tags how to send mail mailmessage

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.