我想使用 gmx smtp 服务器发送一些带有 java 邮件的邮件。我得到的只是这个异常,我应该在异常中查看的页面没有提供如何解决这个问题的信息。
com.sun.mail.smtp.SMTPSendFailedException: 553 5.1.7 Complete address with domain, please ( http://portal.gmx.net/serverrules ) {mp032}
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 553 5.1.7 Complete address with domain, please ( http://portal.gmx.net/serverrules ) {mp032}
我在Java中实现它如下:
props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "mail.gmx.net");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.from", "test@test.test);
props.put("username", "SOMEUSERNAME@gmx.at");
props.put("password", "SOMEPASS");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.debug", "true");
Authenticator auth = new SMTPAuthenticator(props.getProperty("username"), props.getProperty("password"));
if ("true".equals(smtp.getSmtpAuth())) {
mailSession = Session.getDefaultInstance(props, auth);
} else {
mailSession = Session.getDefaultInstance(props);
}
}
class SMTPAuthenticator extends Authenticator {
private String username, password;
public SMTPAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
}