Adia
Adia

Reputation: 1211

Mail repeatedly sent by JavaMail ends up in Spam folder

I'm sending a mail using JavaMail from inside a JSP page as follows:

String from= request.getParameter("from");
String to= request.getParameter("to");
String thanks= request.getParameter("thanks");
String subject= request.getParameter("subject");

try{
    SmtpClient client = new SmtpClient("smtp.example.com");
    client.from(from);
    client.to(to);
    PrintStream message = client.startMessage();
    message.println("From: " + from);
    message.println("To: " + to);
    message.println("Subject: " + subject);
    message.println();
    Enumeration paramNames = request.getParameterNames();

    while(paramNames.hasMoreElements()) {
        String paramName = (String) paramNames.nextElement();
        String paramValue = request.getParameter(paramName);

        if (request.getParameter(paramName) != null && 
            request.getParameter(paramName) != "") {
            message.println(paramName + ": " + paramValue);
            message.println();
        }
    }

    client.closeServer();
}
catch (IOException e){    
    System.out.println("ERROR IN DELIVERING THE FORM:"+e);
}

This was working fine first and sent the data to my Inbox, but after many trials and insignificant changes, now the post goes to my Spam folder.

I appreciate if anyone could tell me where the problem is and what causes this.

Upvotes: 1

Views: 6664

Answers (3)

Ankit Gupta
Ankit Gupta

Reputation: 786

Mail goes to spam when Google find any insecure IP or links, Make sure you don't have any other IP which is not authenticated (can be access by https://"IP")

Upvotes: 2

Ankit Gupta
Ankit Gupta

Reputation: 786

If there is overflow emailId then most of the times it goes to spam, It's done by google. But you can still change that protocol by google by below method:

First time you need to go to your spam and open the mail then the cross option would be above the mail (Which means cancel that mail from spam) click on that (mentioned in the screenshot:. From the next time, it would not go to your spam.

Upvotes: -1

Olaf Kock
Olaf Kock

Reputation: 48067

What causes this? Your spam filter!

Depending on what you/your mail provider uses as spam filter, you might learn something from the mail headers - I recall spamassassin giving some information about what filter scored how high, and the resulting spam score. Others might do that as well.

You might also be able to train your spam filter to recognize this mail as non-spam (ham) if you remove it from the spamfolder.

Upvotes: 1

Related Questions