내가 내 root.xml 파일에 다음과 같은 사항을 작성했습니다SMTP 호스트에 연결할 수 없습니다 : localhost, port : 25?
private void SendEmail(NotificationObject pNotificatonObj,
String[] pReciepientAddresses) throws MessagingException {
log.info("In SendMail");
Properties props = new Properties();
props.put("mail.debug", "true");
props.put("mail.smtp.socketFactory.fallback", "false");
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(
pNotificatonObj.get_From());
msg.setFrom(addressFrom);
// InternetAddress addressTo = new
// InternetAddress(pNotificatonObj.get_To());
InternetAddress[] addressTo = new InternetAddress[pReciepientAddresses.length];
log.info("ADDRESS ARRAY LENGTH In Send Mail: - " + pReciepientAddresses.length);
for (int i = 0; i < pReciepientAddresses.length; i++) {
log.info("ADDRESS ARRAY LENGTH In Send Mail: - " + pReciepientAddresses[i]);
addressTo[i] = new InternetAddress(pReciepientAddresses[i]);
}
// log.info("INTERNET ADRESS ARRAY LENGTH : - " + addressTo1.length);
msg.setRecipients(RecipientType.TO, addressTo);
// msg.addRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(pNotificatonObj.get_Subject());
msg.setContent(pNotificatonObj.get_HtmlString().toString().toString(),
"text/html");
Transport.send(msg);
log.info("Send Mail Leave");
}
내 클래스의 코드를 다음 ... 내가 쓴 메일 알림 기능을 생성 할 class..i 한 사용자 정의하는 Liferay 6를 사용하여 생성하고 디렉토리 tomcatserver
<Resource
name="mail/MailSession"
auth="Container"
type="javax.mail.Session"
mail.imap.host="localhost"
mail.pop.host="localhost"
mail.store.protocol="imap"
mail.transport.protocol="smtp"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="465"
mail.smtp.auth="true"
mail.smtp.starttls.enable="true"
mail.smtp.user="[email protected]" //MyEmailId
password="*******" //My password
mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
/>
하지만 나에게 다음과 같은 오류를주는 ... 사람이 나를 out..where 실수를
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
나는 말했던 방식대로했다. 나는 다음 포털을 ext-porperties 파일에 넣었다. mail.session.jndi.name = mail/MailSession하지만 여전히 동일한 오류가 발생했습니다. –
미안 해요, 당신이 한 일을 이해하지 못합니다. "다음 코드"는 어디에 넣었습니까? 어쩌면 업데이트 된 코드와 구성을 게시 할 수 있습니까? –
http://stackoverflow.com/a/8924168/535646 JNDI 설정에 액세스하는 방법을 참조하십시오. –