私のラップトップ(Windows 10)または開発サーバー(CentOS)でこのJavaサービスを実行すると、 。私たちのライブサーバー(CentOSの)上でそれを実行したときに、私は次のエラーを取得する:私たちのライブサーバーでは、javax.mail.MessagingException:[EOF]取得devのサーバー上で期待どおりに動作します
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を使ってgooglesサーバーに接続することに問題はありません。私は、確かに様々な港の点検をさらに進めるつもりですが、それは問題ではありません。 EDIT 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
[JavaMailデバッグ出力](http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug)の表示内容は何ですか?ライブサーバーにファイアウォールはありますか? [JavaMail FAQの接続デバッグのヒント](http://www.oracle.com/technetwork/java/javamail/faq/index.html#condebug)をお試しください。 –
上記のエラーはログ内の唯一の例外です。 JavaMailのデバッグ出力を具体的に表示する別の方法はありますか?私は上記のエラーがそれだと思った。私は、telnetでグーグルメールサーバに接続できるので、ファイアウォールの問題などのようには思えません。また、このメールサービスの古いバージョンも機能しており、私はその点について何か変更したとは思わない。私の最初の考えは、コードが他のサーバーで動作するので、サーバー自体に何かでなければならないということです。しかし、どこに問題があるのか分かりません。 –
あなたは上のリンクの方法以外に別の方法を意味しますか?さて、あなたはjava.util.loggingを設定することができます。ロガーの詳細は各パッケージの[JavaMail javadocs pages](https://javamail.java.net/nonav/docs/api/)にあります。デバッグ出力が得られない場合は、System.outがどこに行くのか把握する必要があります。これらの[一般的なJavaMailの間違い](http://www.oracle.com/technetwork/java/javamail/faq/index.html#commonmistakes)も修正する必要があります。これにより、いくつかの問題が修正される可能性があります。 –