Я закодировал фрагмент Java ниже (java simple mail 4.4.5):
private String setSOCKS5ProxyAuthentication(String subaccount, String locationId) {
final String encodedSubaccount = new String(Base64.encodeBase64(subaccount.getBytes()));
final String encodedLocationId = new String(Base64.encodeBase64(locationId.getBytes()));
String submitter = "1." + encodedSubaccount + "." + encodedLocationId;
Authenticator.setDefault(new Authenticator() {
@Override
protected java.net.PasswordAuthentication getPasswordAuthentication() {
return new java.net.PasswordAuthentication("1." + encodedSubaccount + "." + encodedLocationId,
new char[] {});
}
});
return submitter;
}
public void sendEmail (Строка из, Строка в, Строка subjectText, Строка mailText) выдает IOException, MessagingException {
String submitter = setSOCKS5ProxyAuthentication("accountname", "location");
Mailer mailer = new Mailer(
new ServerConfig("mailrouter", 9000, "", ""),
TransportStrategy.SMTP_PLAIN,
new ProxyConfig("localhost", 20004, submitter,"password")
);
mailer.sendMail(new EmailBuilder()
.from("mytest", "sender@gmail.com")
.to("test", "receiver@gmail.com")
.subject("This is the subject line")
.textHTML("<h1>This is the actual message</h1>")
.build());
}
Ну, это не работает, так как возникает исключение "Ошибка третьей стороны".Мой SOCKS прокси - localhost: 20004, имя пользователя определено, как указано выше, но пароля нет.Я должен был предоставить поддельный пароль, иначе API вызвал бы исключение.Проверка подлинности отсутствует, а безопасность транспорта отсутствует.Хост почтового сервера: порт - mailrouter: 9000
Что я делаю не так?