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.
解决方案
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.