web-dev-qa-db-ja.com

取得しているjavax.mail.MessagingException:ライブサーバーで[EOF]が、すべてが開発サーバーで期待どおりに機能する

このJavaサービスをラップトップ(Windows 10)または開発サーバー(CentOS)で実行すると、すべて期待どおりに機能します。ただし、ライブサーバー(CentOS)で実行すると、次のエラーが発生します。 :

09/Sep/2016 08:31:07,005 [ERROR] [pool-2-thread-2] - EmailSender: A Messaging exception occurred in EmailSender
javax.mail.MessagingException: [EOF]
        at com.Sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.Java:1363) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.Sun.mail.smtp.SMTPTransport.helo(SMTPTransport.Java:838) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.Sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.Java:375) ~[jar:rsrc:mail-1.4.jar!/:?]
        at javax.mail.Service.connect(Service.Java:275) ~[jar:rsrc:mail-1.4.jar!/:?]
        at javax.mail.Service.connect(Service.Java:156) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.awesomecompany.messaging.server.EmailSender.sendEmail(EmailSender.Java:99) [rsrc:./:?]
        at com.awesomecompany.messaging.server.MonitorDevicesRunnable.run(MonitorDevicesRunnable.Java:82) [rsrc:./:?]
        at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:471) [?:1.7.0_75]
        at Java.util.concurrent.FutureTask.runAndReset(FutureTask.Java:304) [?:1.7.0_75]
        at Java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.Java:178) [?:1.7.0_75]
        at Java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.Java:293) [?:1.7.0_75]
        at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1145) [?:1.7.0_75]
        at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:615) [?:1.7.0_75]
        at Java.lang.Thread.run(Thread.Java:745) [?:1.7.0_75]

私のメールコード:

public void sendEmail(User user) {

        to[0] = user.getEmail();
        Properties props = new Properties();
        props.put("mail.smtp.Host", Host);
        props.put("mail.smtp.user", from);
        props.put("mail.smtp.password", password);
        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.debug", "true");
        props.put("mail.store.protocol", "imap");
        subject = user.getEmailBuilder().getEmailSubject();

        try {

            Session session = Session.getDefaultInstance(props,
                    new Authenticator() {
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication(from,
                                    password);
                        }
                    });

            MimeMessage message = new MimeMessage(session) {
                protected void updateMessageID() throws MessagingException {
                    if (getHeader("Message-ID") == null)
                        super.updateMessageID();
                }
            };
            message.setFrom(new InternetAddress(from));

            InternetAddress[] to_addresses = new InternetAddress[to.length];

            for (int i = 0; i < to.length; i++) {
                to_addresses[i] = new InternetAddress(to[i]);

            }

            message.addRecipients(javax.mail.Message.RecipientType.TO,
                    to_addresses);

            String messageHtml = user.getEmailMessage();
            message.setSubject(subject);
            message.setContent(messageHtml, "text/html;charset=UTF-8;");
            message.saveChanges();
            user.setEmailMessageId(message.getMessageID());
            log.info("Email message ID: " + message.getMessageID());
            Transport transport = session.getTransport("smtp");
            transport.connect(Host, from, password);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();
            user.setEmailStatus(DistinctNotification.STATUS_SENT);

        } catch (AddressException e) {

            log.error("An AddressException occurred in EmailSender", e);
            user.setEmailStatus(DistinctNotification.STATUS_READY);
        } catch (MessagingException e) {

            log.error("A Messaging exception occurred in EmailSender", e);
            user.setEmailStatus(DistinctNotification.STATUS_READY);
        }

    }

エラーは次の行で発生します:

transport.connect(Host, from, password);

編集:

私は、おそらく数か月前に、事実が機能したことを知っている以前のビルドに戻しました。動作しなくなり、同じエラーが発生します。
サーバーにアクセスできる他の同僚は、サーバーに変更を加えていないと述べています。

これでどこへ行けばいいのか全く分かりません。 Telnetを使用してGoogleサーバーに接続しても問題ありません。念のため、さまざまなポートでさらにチェックを行いますが、それは問題ではありません。 編集2:

ここに問題があります:501-5.5.4 Empty HELO/EHLO argument not allowed, closing connection.
しかし、これが1つのサーバーでのみ発生するのはなぜですか?

コンソールからの追加のログ:

DEBUG SMTP: connected to Host "smtp.gmail.com", port: 587

EHLO
501-5.5.4 Empty HELO/EHLO argument not allowed, closing connection.
501 5.5.4  https://support.google.com/mail/?p=helo l10sm686448lfd.19 - gsmtp
HELO
DEBUG SMTP: EOF: [EOF]
09:07:00.277 [pool-2-thread-1] - A Messaging exception occurred in EmailSender
javax.mail.MessagingException: [EOF]
        at com.Sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.Java:1363) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.Sun.mail.smtp.SMTPTransport.helo(SMTPTransport.Java:838) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.Sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.Java:375) ~[jar:rsrc:mail-1.4.jar!/:?]
        at javax.mail.Service.connect(Service.Java:275) ~[jar:rsrc:mail-1.4.jar!/:?]
        at javax.mail.Service.connect(Service.Java:156) ~[jar:rsrc:mail-1.4.jar!/:?]
        at com.watersprint.messaging.server.EmailSender.sendEmail(EmailSender.Java:99) [rsrc:./:?]
        at com.watersprint.messaging.server.MonitorDevicesRunnable.run(MonitorDevicesRunnable.Java:82) [rsrc:./:?]
        at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:471) [?:1.7.0_75]
        at Java.util.concurrent.FutureTask.runAndReset(FutureTask.Java:304) [?:1.7.0_75]
        at Java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.Java:178) [?:1.7.0_75]
        at Java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.Java:293) [?:1.7.0_75]
        at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1145) [?:1.7.0_75]
        at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:615) [?:1.7.0_75]
        at Java.lang.Thread.run(Thread.Java:745) [?:1.7.0_75]
2016-09-15 09:07:00,760 ERROR Error occurred while sending e-mail notification. javax.mail.MessagingException: [EOF]
        at com.Sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.Java:1363)
        at com.Sun.mail.smtp.SMTPTransport.helo(SMTPTransport.Java:838)
        at com.Sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.Java:375)
        at javax.mail.Service.connect(Service.Java:297)
        at javax.mail.Service.connect(Service.Java:156)
        at javax.mail.Service.connect(Service.Java:105)
        at javax.mail.Transport.send0(Transport.Java:168)
        at javax.mail.Transport.send(Transport.Java:98)
        at org.Apache.logging.log4j.core.net.SmtpManager.sendMultipartMessage(SmtpManager.Java:241)
        at org.Apache.logging.log4j.core.net.SmtpManager.sendEvents(SmtpManager.Java:150)
        at org.Apache.logging.log4j.core.appender.SmtpAppender.append(SmtpAppender.Java:173)
        at org.Apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.Java:99)
        at org.Apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.Java:430)
        at org.Apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.Java:409)
        at org.Apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.Java:367)
        at org.Apache.logging.log4j.core.Logger.logMessage(Logger.Java:112)
        at org.Apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.Java:727)
        at org.Apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.Java:716)
        at org.Apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.Java:354)
        at com.watersprint.messaging.server.EmailSender.sendEmail(EmailSender.Java:110)
        at com.watersprint.messaging.server.MonitorDevicesRunnable.run(MonitorDevicesRunnable.Java:82)
        at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:471)
        at Java.util.concurrent.FutureTask.runAndReset(FutureTask.Java:304)
        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:745)

2016-09-15 09:07:00,762 ERROR An exception occurred processing Appender SMTPAppender org.Apache.logging.log4j.LoggingException: Error occurred while sending email
        at org.Apache.logging.log4j.core.net.SmtpManager.sendEvents(SmtpManager.Java:153)
        at org.Apache.logging.log4j.core.appender.SmtpAppender.append(SmtpAppender.Java:173)
        at org.Apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.Java:99)
        at org.Apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.Java:430)
        at org.Apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.Java:409)
        at org.Apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.Java:367)
        at org.Apache.logging.log4j.core.Logger.logMessage(Logger.Java:112)
        at org.Apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.Java:727)
        at org.Apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.Java:716)
        at org.Apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.Java:354)
        at com.watersprint.messaging.server.EmailSender.sendEmail(EmailSender.Java:110)
        at com.watersprint.messaging.server.MonitorDevicesRunnable.run(MonitorDevicesRunnable.Java:82)
        at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:471)
        at Java.util.concurrent.FutureTask.runAndReset(FutureTask.Java:304)
        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:745)
Caused by: javax.mail.MessagingException: [EOF]
        at com.Sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.Java:1363)
        at com.Sun.mail.smtp.SMTPTransport.helo(SMTPTransport.Java:838)
        at com.Sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.Java:375)
        at javax.mail.Service.connect(Service.Java:297)
        at javax.mail.Service.connect(Service.Java:156)
        at javax.mail.Service.connect(Service.Java:105)
        at javax.mail.Transport.send0(Transport.Java:168)
        at javax.mail.Transport.send(Transport.Java:98)
        at org.Apache.logging.log4j.core.net.SmtpManager.sendMultipartMessage(SmtpManager.Java:241)
        at org.Apache.logging.log4j.core.net.SmtpManager.sendEvents(SmtpManager.Java:150)
        ... 18 more
15
bot_bot

サーバー$HOSTNAME/etc/hostsから削除されました。その結果、Googleサーバーはホスト名としてnullまたは空の値を受け取り、接続を拒否しました。

12
bot_bot