Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javax.mail.SendFailedException:发送失败;嵌套异常为:类javax.mail.MessaginException:未知SMTP主机:relay.jangosmtp.net; 我想将我的Jsp连接到电子邮件。我正在使用ApacheTomcat服务器。我引用此链接来完成它:-但我得到的错误如下:-_Jsp_Email_Session_Tomcat_Smtp - Fatal编程技术网

javax.mail.SendFailedException:发送失败;嵌套异常为:类javax.mail.MessaginException:未知SMTP主机:relay.jangosmtp.net; 我想将我的Jsp连接到电子邮件。我正在使用ApacheTomcat服务器。我引用此链接来完成它:-但我得到的错误如下:-

javax.mail.SendFailedException:发送失败;嵌套异常为:类javax.mail.MessaginException:未知SMTP主机:relay.jangosmtp.net; 我想将我的Jsp连接到电子邮件。我正在使用ApacheTomcat服务器。我引用此链接来完成它:-但我得到的错误如下:-,jsp,email,session,tomcat,smtp,Jsp,Email,Session,Tomcat,Smtp,我真的确信问题在哪里。请帮我纠正这个错误。提前谢谢 这是我的index.html:- 还有一个问题:-在JangoSMTP创建了一个免费帐户后,它表示要为web应用程序提供IP地址。当我在本地机器上使用Tomcat服务器时,如何做到这一点。这可能是我出错的原因吗?看起来有DNS解析问题。尝试使用ip地址209.173.141.243而不是主机名relay.jangosmtp.net来修复您的本地DNS设置。因此,我尝试过这样做,但现在我得到的错误消息是:-------javax.mail.Sen

我真的确信问题在哪里。请帮我纠正这个错误。提前谢谢

这是我的index.html:-
还有一个问题:-在JangoSMTP创建了一个免费帐户后,它表示要为web应用程序提供IP地址。当我在本地机器上使用Tomcat服务器时,如何做到这一点。这可能是我出错的原因吗?

看起来有DNS解析问题。尝试使用ip地址209.173.141.243而不是主机名relay.jangosmtp.net来修复您的本地DNS设置。因此,我尝试过这样做,但现在我得到的错误消息是:-------javax.mail.SendFailedException:发送失败;嵌套异常为:类javax.mail.MessaginException:无法连接到SMTP主机:209.173.141.243,端口:25;嵌套异常是:java.net.ConnectException:Connection timed out:connect------------------那么,我应该如何修复它?您能够从命令行telnet 209.173.141.243 25吗?不!它告诉我telnet不被识别为内部/外部命令!因此,您需要首先启用它:
javax.mail.SendFailedException: Sending failed;
  nested exception is:
    class javax.mail.MessagingException: Unknown SMTP host: relay.jangosmtp.net;
  nested exception is:
    java.net.UnknownHostException: relay.jangosmtp.net
<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
    <%@ page import="javax.mail.internet.*,javax.activation.*"%>
    <%@ page import="javax.servlet.http.*,javax.servlet.*"%>
    <%
        String result;
        //Recipient's email ID needs to be mentioned.
        String to = "abc@gmail.com";

        // Sender's email ID needs to be mentioned
        String from = "abc@gmail.com";
        final String username = "username";
        final String password = "251497PF";

        // Assuming you are sending email through relay.jangosmtp.net
        String host = "relay.jangosmtp.net";

        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", host);
        props.put("mail.smtp.port", "25");

        //Get the Session object.
        Session mailSession = Session.getInstance(props,
                new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(username,
                                password);
                    }
                });

        try {
            // Create a default MimeMessage object.
            Message message = new MimeMessage(mailSession);

            // Set From: header field of the header.
            message.setFrom(new InternetAddress(from));

            // Set To: header field of the header.
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse(to));

            // Set Subject: header field
            message.setSubject("Testing Subject");

            // Now set the actual message
            message.setText("Hello, this is sample for to check send "
                    + "email using JavaMailAPI in JSP ");

            // Send message
            Transport.send(message);

            System.out.println("Sent message successfully....");
            result = "Sent message successfully....";

        } catch (MessagingException e) {
            e.printStackTrace();
            result = "Error: unable to send message....";

        }
    %>
    <html>
    <head>
    <title>Send Email using JSP</title>
    </head>
    <body>
        <center>
            <h1>Send Email using JSP</h1>
        </center>
        <p align="center">
            <%
                out.println("Result: " + result + "\n");
            %>
        </p>
    </body>