java - 通过Java发送邮件

标签 java email centos postfix-mta

我在发送 java 邮件时在 centOS 服务器上遇到问题。出现以下异常。

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25, response: -1

<小时/>

我在命令提示符下使用了以下命令,并按预期收到了邮件。

echo "testing" | mail -s"test subject" shantanu.oa@gmail.com
<小时/>

邮件日志中的相关条目如下所示...

Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms
Mar 28 20:13:17 postfix/master[28163]: warning: process /usr/libexec/postfix/smtpd pid 10120 exit status 1
Mar 28 20:13:17 postfix/master[28163]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
Mar 28 20:26:22 postfix/smtpd[11001]: warning: SASL: Connect to private/auth failed: Connection refused

如何解决这个问题?

最佳答案

来自日志条目

Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms

我怀疑问题出在 Postfix 上,我不是这方面的专家。谷歌搜索“致命:没有 SASL 身份验证机制”给出了很多有趣的链接:也许看看 herehere .

关于java - 通过Java发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5469362/

相关文章:

java - 嵌套accept()以获取一个字符串数组中子目录中的文件

PHP mail() 函数 ... 已发送空邮件

centos - 在 rpm .spec 文件中检测平台

centos - docker 灯 Centos7 : '/bin/sh -c systemctl start httpd.service' returned a non-zero code: 1

java - LDAP 搜索速度很慢

java - 通过与另一个 Set 中的键匹配来添加 Map 中的 BigDecimals

c# - 发送带有 SendGrid 和空值的邮件?

java - Gmail REST API : Using Google Credentials Without Impersonate

java - Swing 设置框架在 CentOS 中的位置

java - Java应用服务器利用304 HTTP响应将数据缓存到JavaScript中是否正常