Ich habe Java-Mail-API verwendet, um E-Mails von Google Mail, Hotmail und Outlook zu senden. Es funktionierte gut mit Google Mail und Hotmail, , funktioniert aber nicht auf Outlook.JavaMail-Ausnahme: STOREDRV.Submission.Exception: OutboundSpamException
-Code für Outlook Sender Klasse
public class OutlookSender extends javax.mail.Authenticator {
private String mailhost = "smtp-mail.outlook.com";
private String user;
private String password;
private Session session;
static {
Security.addProvider(new JSSEProvider());
}
public OutlookSender(String user, String password) {
this.user = user;
this.password = password;
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", "587");
session = Session.getDefaultInstance(props, this);
session.setDebug(true);
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
public synchronized void sendMail(String subject, String body,
String sender, String recipients) throws Exception {
MimeMessage message = new MimeMessage(session);
DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
message.setSender(new InternetAddress(sender));
message.setSubject(subject);
message.setDataHandler(handler);
if (recipients.indexOf(',') > 0){
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
} else{
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
}
message.saveChanges();
//Transport trans = session.getTransport("smtp");
Transport transport = session.getTransport("smtp");
transport.connect(mailhost, user, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
}
-Code E-Mail senden:
OutlookSender sender = new OutlookSender("[email protected]", "password");
sender.sendMail("Hello Text", "Body Text Sample", "[email protected]", "[email protected]");
Nach der Sendung, habe ich eine Ausnahme von logcat mit Inhalt:
javax.mail.MessagingException: 554-554 5.2.0 STOREDRV.Submission.Exception:OutboundSpamException; Failed to process message due to a permanent exception with message WASCL UserAction verdict is not None. Actual verdict is HipSend...
Bitte erläutern Sie den Grund der Ausnahme und wie Sie dieses Problem beheben können. Vielen Dank.
Es sieht aus wie Outlook.com denkt, dass Sie Spam senden. Was zeigt die [JavaMail-Debugausgabe] (http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug)? –
@BillShannon, es zeigt nichts. – CauCuKien
Wenn es nichts zeigt, machst du es nicht richtig. –