- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在我的笔记本电脑 (Windows 10) 或我们的开发服务器 (CentOS) 上运行此 Java 服务,一切都按预期进行。但是当我在我们的实时服务器 (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 联系 googles 服务器没有问题。为了确定,我将对各种端口进行更多检查,但我不认为这是问题所在。编辑 2:
这是问题所在:501-5.5.4 不允许空 HELO/EHLO 参数,正在关闭连接。
但为什么这只会发生在一台服务器上?
来自控制台的其他日志:
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
最佳答案
不知何故,服务器 $HOSTNAME
已从 /etc/hosts
中删除。结果,googles 服务器收到了一个 null
或一个空值作为主机名并拒绝了连接。
关于java - 获取 javax.mail.MessagingException : [EOF] on our live server, 但在我们的开发服务器上一切都按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39406266/
读取文件时,我知道提供的最后一个字符是 EOF。现在,当我有 EOF 时会发生什么?该文件中的字符? 如何区分文件的“真实”结尾和 EOF特点? 最佳答案 我决定将我的评论移至答案。 您的文件中不能有
GNU Bash - 3.6.6 Here Documents [n]<<[-]word here-document delimiter If any part of word is
试图查看论坛但无法重新访问。 我正在尝试阅读文本。文字是:“给 b” 但是在使用 fgetc() 时,没有达到 EOF,最后我得到 '\n',然后是无穷大的 'y' 样本。 这是我的代码: Node*
我正在做一个非常简单的作业,需要输出文件的内容,但在做任何事情之前我意外地到达了 EOF。该文件仅包含单词“pig”,并且由于某种原因 EOF 返回 16。我正在使用 Dev-Cpp 并且该程序是用
我的 kubectl 无法读取文件,每次都返回 'error: unexpected EOF'。 kubectl apply -f service.yaml > error: unexpected E
我想知道什么时候使用 cat Hello world! () { setopt localoptions shnullcmd test-nullcmd } # nothing will be
我试图找出我正在向其中写入特定数据的文件中不需要的尾随结束数据的原因,并且不相信我在写入文件时出错。 输出如下: building room_numbr capacity packard
考虑下面的简单例子 #include #include #include using namespace std; int main() { string str = "string";
我在一个程序中有这个片段(在 Visual Studio 2005 中): if(_eof(fp->_file)) { break; } 当达到 eof 时,它打破了封闭循环。但是程序无法解析
我正在尝试为 Typed Racket 中的以下函数定义类型注释: (define (neof x) (if (eof-object? x) #f x)) 不加注释给出了类型: (Any ->
我正在为 Linux 构建系统的模块编写 .spec 文件,遇到一个小问题并想分享它。 用于编写脚本文件: cat /path/to/somewhere/script #blah blah EOF
我有一个 C++ 程序,它从一个文件中读取我希望有一堆格式相同的记录。如果遇到意外情况,无论是记录格式不正确还是输入失败,我都想停止阅读,我想区分这些不同的情况。 我看过 this answer并查看
我注意到它们之间的几个区别: 在 <
预期我正在生成子进程并执行“ssh”远程框。从最近几天开始它工作正常,现在突然间,每当我尝试生成子进程时,它都会抛出错误。不确定发生了什么。 直到现在我一直在使用 pexpect 3.1,我遇到了这个
这个问题已经有答案了: Why two EOF needed as input? [duplicate] (2 个回答) Why do I require multiple EOF (CTRL+Z)
我正在浏览一个文件来寻找特定的词 Char[50]=getline(file,/n) 使用 getline 将每一行存储到一个 char 数组中以与我要查找的字符串进行比较 If( “”==char[
引用两个问题: Incorrect output from C++ Primer 1.4.4 Confused by control flow execution in C++ Primer exam
我刚刚在 this 中找到一条评论回答说在循环条件中使用 iostream::eof “几乎肯定是错误的”。我通常使用类似 while(cin>>n) 的东西——我猜它会隐式检查 EOF。 为什么使用
我刚刚在 this 中找到一条评论回答说在循环条件中使用 iostream::eof “几乎肯定是错误的”。我通常使用类似 while(cin>>n) 的东西——我猜它会隐式检查 EOF。 为什么使用
我刚刚在 this 中找到一条评论回答说在循环条件中使用 iostream::eof “几乎肯定是错误的”。我通常使用类似 while(cin>>n) 的东西——我猜它会隐式检查 EOF。 为什么使用
我是一名优秀的程序员,十分优秀!