tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Elkjær <mar...@elkjaer-it.dk>
Subject Sending mails from OpenEJB
Date Fri, 20 Nov 2009 19:45:09 GMT
Hi,

I'm trying to send mails from google. I had a setup from a plain tomcat
install (without OpenEJB) that works. My resource looks like this :

<Resource  id="mtdMail" type="javax.mail.Session">
mail.smtp.starttls.enable="true"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="587"
mail.transport.protocol="smtps"
mail.smtp.auth="true"
mail.smtp.from="XXXXXXXXXXX"
mail.smtp.user="XXXXXXXXXXX"
password="XXXXXXX"
/>


I have a very simple mail bean:
-------------------------------------------------
@Stateless
public class MailSender implements MailSenderLocal {
@Resource
Session mtdMail;
 @Override
public void sendMail(String to, String subject, String content) {
Message msg = new MimeMessage(mtdMail);
        try {
msg.setFrom(new InternetAddress("noreply@mintraeningsdagbog.dk",
"MinTræningsDagbog.dk"));
msg.setRecipient(RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
            MimeBodyPart mbp1 = new MimeBodyPart();
            mbp1.setText(content);
            Multipart mp = new MimeMultipart();
            mp.addBodyPart(mbp1);
            msg.setContent(mp);
            Transport.send(msg);
} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
}

---------------------------------------------------------

The exception thrown is:

DEBUG: getProvider() returning
javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at
dk.elkjaerit.mtd.server.services.impl.MailSender.sendMail(MailSender.java:53)



Anyone managed to send mails from OpenEJB ?
And as I said - it's working from a plain Tomcat setup..


Best regards
Martin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message