그것은 회사의 릴레이 SMTP 서버가 도메인 (예 : ANYUSERNAME의 @의 COMPANYNAME이있는 위장 된 이메일 주소를 사용하여 인증없이 사용할 수 있습니다 밝혀 : 여기
content = "message content";
List<String> recipients = LIST_OF_RECIPIENT_EMAIL_ADDRESSES;
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "SMTPRELAY.COMPANYNAME.COM");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.ssl.trust", "SMTPRELAY.COMPANYNAME.COM");
props.put("mail.debug", "true");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
//This is where the email account name and password are set
return new PasswordAuthentication("[email protected]", "PASSWORD");
}
});
try{
MimeMessage message = new MimeMessage(session);
message.setReplyTo(new Address[]{new InternetAddress("[email protected]")});
for(String recipient: recipients){
message.addRecipient(Message.RecipientType.BCC,new InternetAddress(recipient));
}
message.setSubject(subject);
message.setContent(content,"text/html");
Transport.send(message);
return true;
}catch (MessagingException mex) {
mex.printStackTrace();
return false;
}
내가 점점 계속 오류입니다. COM). 따라서 smtp.gmail.com에 대한 인증 필요가 없습니다.
실제 메시지를 다른 메시지를 통해 보내는 동안 차단 된 smtp에 대해 인증 할 수 있는지 궁금한 점이 있습니다. 하지만 내 문제가 해결되었습니다.
당신은 그것을 할 수 있지만, 기본적으로 그냥에서 내 원래의 질문에 코드를 변경하는 방법을 찾아 볼 수있는 많은 장소가 인증없이 이메일을 보내는 방법을 궁금해하는 경우 :
props.put("mail.smtp.auth", "true");
.
.
.
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(email+"@"+domain, password);
}
});
변경 위의 부분이
props.put("mail.smtp.auth", "false");
.
.
.
Session session = Session.getInstance(props);
이 제한 사항을 피하기 위해 smtp.gmail.com에 465 번 포트로 연결할 수 있습니까? – wasabi
Nope. 우리는 고객이 포트 25 만 사용하도록 지시 받았습니다. 다른 포트는 차단됩니다. – Sunga