1

setHostName("mail.metaregistrar.com") を設定し、ローカルホストで SMTP を使用してメールを送信するのはなぜですか?

Java コード:

SimpleEmail email = new SimpleEmail();
            email.setHostName(host);
            email.setStartTLSEnabled(true);

            email.setSmtpPort(25);
            email.setAuthenticator(new DefaultAuthenticator(username, password));
            email.setFrom(from);
            email.setSubject(subject);
            email.setMsg(message);
            for (String address : addresses) {
                email.addTo(address);
            }
            email.send();  

例外スタック トレース:

org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.metaregistrar.com:25
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1401)
    at org.apache.commons.mail.Email.send(Email.java:1428)
    at com.metaregistrar.mailer.Mailer.mail(Mailer.java:66)
    at com.metaregistrarv2.schedule.ExternalPollMessageIisseHandler.handleUpdateMessage(ExternalPollMessageIisseHandler.java:88)
    at com.metaregistrarv2.schedule.ExternalPollMessageIisseHandler.handleExternalPollMessage(ExternalPollMessageIisseHandler.java:67)
    at com.metaregistrarv2.schedule.PollTaskTimer.handleStoredMessages(PollTaskTimer.java:58)
    at com.metaregistrarv2.schedule.PollTaskTimer.execute(PollTaskTimer.java:38)
    at com.metaregistrarv2.schedule.EppPollerTimedTaskAdapter.execute(EppPollerTimedTaskAdapter.java:28)
    at com.metaregistrar.scheduling.TimedTask.run(TimedTask.java:22)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
    at com.metaregistrar.concurrent.PoolThread.run(PoolThread.java:26)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25 (java.net.ConnectException: Connection refused))
    at javax.mail.Transport.send(Transport.java:163)
    at javax.mail.Transport.send(Transport.java:48)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1391)
    ... 17 more
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25 (java.net.ConnectException: Connection refused)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
    at javax.mail.Service.connect(Service.java:254)
    at javax.mail.Service.connect(Service.java:85)
    at javax.mail.Service.connect(Service.java:70)
    at javax.mail.Transport.send(Transport.java:94)
    ... 19 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927)
    ... 24 more
4

1 に答える 1