0
следующий код для отправки электронной почты через наш собственный сервер дает AuthenticationFailedExceptionAuthenticationFailedException: не удалось подключиться ошибка при отправке электронной почты
String to = "[email protected]";
String from = "[email protected]";
String host = "Mail.abc.co.in";
String message= null;
Properties props = System.getProperties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", "587");
Session session = Session.getDefaultInstance(props);
InternetAddress fromAddress = null;
InternetAddress toAddress = null;
try {
Message simpleMessage = new MimeMessage(session);
fromAddress = new InternetAddress(from);
toAddress = new InternetAddress(to);
simpleMessage.setFrom(fromAddress);
simpleMessage.setRecipient(RecipientType.TO, toAddress);
simpleMessage.setSubject("-------------");
simpleMessage.setContent(message, "text/html");
Transport trans = session.getTransport("smtp");
trans.connect("Mail.abc.co.in", 587, "[email protected]", "password");
trans.sendMessage(simpleMessage, simpleMessage.getAllRecipients());
} catch (MessagingException e) {
e.printStackTrace();
}
помощь в Выяснить проблемы Спасибо advanve
Но у меня есть свой собственный сервер рассылки и я хочу сделать почту, используя только этот сервер. – Betty
@Betty Также я заметил, что вы используете экземпляр по умолчанию 'Session' без' Authentificator'. Лучше обновите свой вопрос и укажите, что вы используете свой собственный сервер. –