当前位置:编程学习 > JSP >>

javamail如何向163发邮件

我的代码是这样的:
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("发送成功!!");
        }catch(Exception e){
            out.print("发送失败!!");
            System.out.println(e);
        }


在"邮件服务器"上输入:stmp.163.com提交后,无法发送邮件,错误是:
javax.mail.MessagingException: Unknown SMTP host: stmp.163.com;
  nested exception is:
    java.net.UnknownHostException: stmp.163.com

补充:Jsp教程,邮件
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,