JamesServer发送的电子邮件被标记为垃圾邮件。我正在使用JavaMail连接到JamesServer来发送电子邮件。
要测试垃圾邮件,我使用的是mail-tester.com网站。该网站告诉我,该电子邮件被标记为垃圾邮件,其下方为负阈值:
-3.603 HELO_LOCALHOST HELO_LOCALHOST
我根据网站发现了helo和ehlo参数。要覆盖helo和ehlo,我使用了“mail.smtp.localhost”属性。但我能够改变ehlo,但我无法改变他的价值。
如何更改helo参数的值?
这是我的java示例代码:
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class TestSendMail {
private String fromEmail = "admin@xxxxxxxxxx.com";
public void sendmail() {
Properties properties = new Properties();
final String smtpHost = "xxxxxxxxxx.com";
String port = "25";
String strHostName = smtpHost;
try {
strHostName = InetAddress.getLocalHost().getHostName();
System.out.println(strHostName);
} catch (UnknownHostException e) {
}
properties.put("helo", strHostName );
properties.put("mail.host", strHostName );
properties.put("mail.smtp.localhost", strHostName );
properties.put("mail.smtps.localhost", strHostName);
properties.put("mail.smtp.host", smtpHost);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.transport.protocol", "smtp");
Session session = Session.getInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(fromEmail,"Welcome123!");
}
});
String toEmail = "web-3a2Lxc@mail-tester.com";
String replyTo = "noreply@" + smtpHost;
String messageBody = "<html><body>Test body</body></html>";
try {
MimeMessage message = new MimeMessage(session);
message.setSentDate(new Date());
message.setFrom(new InternetAddress(fromEmail));
message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(toEmail));
message.setSubject("Test");
message.setReplyTo(new javax.mail.Address[]
{
new InternetAddress(replyTo)
});
message.setContent(messageBody, "text/html");
Transport.send(message);
System.out.println("Message sent successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
System.out.println(mex.getMessage());
}
}
public static void main(String[] args) {
TestSendMail send = new TestSendMail();
send.sendmail();
}
}
这是我从mail-tester.com
获取的电子邮件日志 Received: by mail-tester.com (Postfix, from userid 500) id F01C8A0C53;
Fri, 5 Jun 2015 14:01:09 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail-tester.com
X-Spam-Flag: YES
X-Spam-Level: *****
X-Spam-Status: Yes/6.0/5.0
X-Spam-Test-Scores: FSL_HELO_NON_FQDN_1=0.001,HELO_LOCALHOST=3.603,
HTML_MESSAGE=0.001,MIME_HTML_ONLY=1.105,RDNS_NONE=1.274
X-Spam-Last-External-IP: 128.199.181.189
X-Spam-Last-External-HELO: localhost
X-Spam-Last-External-rDNS:
X-Spam-Date-of-Scan: Fri, 05 Jun 2015 14:01:09 +0200
X-Spam-Report: * 3.6 HELO_LOCALHOST No description available. * 0.0
FSL_HELO_NON_FQDN_1 No description available. * 1.1 MIME_HTML_ONLY BODY:
Message only has text/html MIME parts * 0.0 HTML_MESSAGE BODY: HTML
included in message * 1.3 RDNS_NONE Delivered to internal network by a
host with no rDNS
Received-SPF: None (no SPF record) identity=mailfrom;
client-ip=128.199.181.189; helo=localhost;
envelope-from=admin@xxxxxxxxxx.com; receiver=web-3a2lxc@mail-tester.com
Authentication-Results: mail-tester.com; dmarc=none
header.from=xxxxxxxxxx.com
Received: from localhost (unknown [128.199.181.189])
by mail-tester.com (Postfix) with ESMTP id 2B6E09F862
for <web-3a2Lx@mail-tester.com>; Fri, 5 Jun 2015 14:01:07 +0200 (CEST)
MIME-Version: 1.0
X-UserIsAuth: true
Received: from 122.175.7.239 (EHLO USER-PC) ([122.175.7.239])
by xxxxxxxxxx-01 (JAMES SMTP Server ) with ESMTPA ID 1021366912
for <web-3a2Lx@mail-tester.com>;
Fri, 05 Jun 2015 08:02:40 -0400 (EDT)
Date: Fri, 5 Jun 2015 17:32:44 +0530 (IST)
From: admin@xxxxxxxxxx.com
Reply-To: noreply@xxxxxxxxxx.com
To: web-3a2Lx@mail-tester.com
Message-ID: <17905416.0.1433505764473.JavaMail.USER@USER-PC>
Subject: Test
Return-Path: admin@xxxxxxxxxx.com
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<html><body>Test body</body></html>
感谢任何帮助。
答案 0 :(得分:1)
您是否正在使用JavaMail将消息发送到Apache James服务器,然后将其发送到mail-tester.com?如果是这样,那么您需要担心的是Apache James配置,而不是JavaMail配置。请注意,在单个SMTP会话中只使用HELO或EHLO中的一个。
看起来你的Apache James服务器在与mail-tester.com交谈时正在使用HELO,并且没有使用服务器的完整DNS名称正确识别自己。确保您的服务器具有 DNS名称(而不仅仅是DHCP获取的IP地址),并且服务器上的名称服务已正确配置为知道服务器的DNS名称。
答案 1 :(得分:0)
可能是因为来自地址的域名为admin@xxxxxxxx.com 这不会解析为任何特定的已知主机。删除后尝试。如果您的邮件仍标记为垃圾邮件,则必须知道在接收方端应用的过滤器。