1

Email sent from JamesServer are marked as spam. I am using JavaMail to connect to JamesServer to send emails.

To test spam, I am using the mail-tester.com site. This site tells me the email are marked as spam with a negative threshold for below:

  -3.603        HELO_LOCALHOST      HELO_LOCALHOST

I came across helo and ehlo parameter based on the site. To override helo and ehlo, I have used "mail.smtp.localhost" property. But I was able to change ehlo but I am not able to change helo value.

How do I change value of helo parameter?

Here is my java sample code:

    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();
        }
    }

Here is my email log which I got it from 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>

Any help is appreciated.

User12111111
  • 1,179
  • 1
  • 19
  • 41

3 Answers3

2

Are you using JavaMail to send the message to your Apache James server, which is then sending it on to mail-tester.com? If so, it's the Apache James configuration you need to worry about, not the JavaMail configuration. Note that only one of HELO or EHLO is used in a single SMTP conversation.

It looks like your Apache James server is using HELO when talking to mail-tester.com, and is not identifying itself properly using the full DNS name of your server. Make sure your server has a DNS name (not just a DHCP acquired IP address) and the name service on the server is properly configured to know the DNS name of the server.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
0

Probably it might be due to the domain of from address i.e. admin@xxxxxxxx.com This would not resolve to any particular known hosts.So try after removing it. If your mail is still marked as SPAM, you have to know the filters applied at the receiver's end.

0
$ sudo nano /etc/postfix/main.cf

change: myhostname = DOMAIN.TLD

$ sudo systemctl restart postfix
jmoerdyk
  • 5,544
  • 7
  • 38
  • 49
Ei Dotter
  • 1
  • 1