Reputation: 61
I have a little trouble.
I configured mail session on wildfly 9.
<subsystem xmlns="urn:jboss:domain:mail:2.0">
<mail-session name="AppSrvMail" jndi-name="java:jboss/mail/AppSrvMail">
<smtp-server outbound-socket-binding-ref="mail-smtp" ssl="false" username="[email protected]" password="example"/>
</mail-session>
</subsystem>
...
<outbound-socket-binding name="mail-smtp">
<remote-destination host="host.example.com" port="25"/>
</outbound-socket-binding>
after that i inject in stateless bean resource:
@Resource(name = "java:jboss/mail/AppSrvMail")
private Session session;
and method:
@Override
public void send(String address, String topic, String textMessage) {
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
Address toAddress = new InternetAddress(address);
message.addRecipient(Message.RecipientType.TO, toAddress);
message.setSubject(topic);
message.setContent(textMessage, CONTENT_TYPE_HTML);
Transport.send(message);
Transport.send(message);
} catch (MessagingException e) {
LOG.log("Cannot send mail", e);
}
}
After that all right, code is working, but all receivers that i send have double messages. Exactly, wilfly send the same email twice.
If i connecting this account in to client (for example, evolution client in linux) and send message - receiver get one message, it's ok.
Someone know's what's goin on?
Please, help me.
Upvotes: 1
Views: 376
Reputation: 12875
Your send()
method contains a duplicate line:
Transport.send(message);
Upvotes: 4