本地主机A的查找未完成

时间:2019-09-13 11:21:48

标签: java apache email mx-record james

我已经在本地和远程桌面上安装了Apache James服务器,并创建了2个不同的域,其中一个是Test.com,第二个是sample.com             我正在尝试通过测试域向示例域Apache James发送邮件到远程域,但它显示             无法解析域sample.com的MX记录。

我尝试了很多

import java.io.UnsupportedEncodingException;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class LocalMailTest {

    public static void main(String[] args) throws UnsupportedEncodingException {

        final String username = "admin@test.com";
        final String password = "admin";

        Properties prop = new Properties();
        prop.put("mail.smtp.host", "127.0.0.1");
        prop.put("mail.smtp.port", "25");
        prop.put("mail.smtp.auth", "true");
        prop.put("mail.smtp.starttls.enable", "flase"); //TLS
        prop.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");


        Session session = Session.getInstance(prop,new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(username, password);
                    }
                });

        try {
            MimeMessage message = new MimeMessage(session);
            message.setFrom(new InternetAddress(username));
            message.addRecipient(Message.RecipientType.TO, new InternetAddress("admin@sample.com"));
            message.setSubject("Sample");
            message.setText("Hi this is bharath");  // send the message
            Transport.send(message);

            System.out.println("message sent successfully...");

        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}

日志中的错误:

INFO  16:33:28,481 | org.apache.james.dnsservice.dnsjava.DNSJavaService | Couldn't resolve MX records for domain sample.com.
INFO  16:33:39,290 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection established from 127.0.0.1
INFO  16:33:39,486 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection closed for 127.0.0.1
INFO  16:33:49,572 | org.apache.james.transport.mailets.remote.delivery.MailDelivrer | Couldn't connect to host, port: 52.205.207.109, 25; timeout 60000
ERROR 16:34:10,451 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Unable to process request
java.io.IOException: An existing connection was forcibly closed by the remote host
        at sun.nio.ch.SocketDispatcher.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(Unknown Source)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
        at sun.nio.ch.IOUtil.read(Unknown Source)
        at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:64)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
INFO  16:34:10,458 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection closed for 127.0.0.1
INFO  16:34:10,590 | org.apache.james.transport.mailets.remote.delivery.MailDelivrer | Couldn't connect to host, port: 3.227.140.41, 25; timeout 60000
INFO  16:34:16,087 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection established from 127.0.0.1
INFO  16:34:16,127 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection established from 127.0.0.1
INFO  16:34:16,133 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Unable to process request
java.nio.channels.ClosedChannelException
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:433)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:373)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:93)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
        at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
INFO  16:34:16,133 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Unable to process request
java.nio.channels.ClosedChannelException

0 个答案:

没有答案