Unable to send emails from the plugin

Oxygen general issues.
bugi
Posts: 7
Joined: Wed Aug 21, 2013 3:33 pm

Unable to send emails from the plugin

Post by bugi »

Hi guys,
I am developing plugin for Oxygen editor.
Among other things it requires email sending form the plugin code.
I created email sending logic based on java mail api. It works fine when I run it from the unit test.
Once I wrap this email sending logic into the plugin and start Oxygen the email is not getting sent, no error messages, just silence.
I use smtp.jar, mail.jar and mailapi.jar in the class path
Am I missing something?

Please help!
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: Unable to send emails from the plugin

Post by Radu »

Hi,

So you added those required JAR libraries to the plugin.xml, right?
If you start Oxygen using the oxygen.bat command line executable, is there any error reported in the console?
If you wrap all your code in a

Code: Select all


try{
}catch(Exception ex){
ex.printStackTrace();
}
is there any exception stack trace reported in the console?

By the way, we have a topic which explains how you could test your plugin with Oxygen as a JUnit test case:

http://www.oxygenxml.com/doc/ug-oxygen/ ... tests.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bugi
Posts: 7
Joined: Wed Aug 21, 2013 3:33 pm

Re: Unable to send emails from the plugin

Post by bugi »

Yep,

I wrapped it up with try/catch. No errors detected but the email is not getting sent.

here is my email sending code
Properties properties = System.getProperties();
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.port", 587);
properties.put("mail.smtp.user", "XXX@gmail.com");
properties.put("mail.smtp.auth", true);
properties.put("mail.smtp.timeout", 60000);
properties.put("mail.smtp.starttls.enable", true);

Session session = Session.getInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("XXX@gmail.com", "ZZZ");
}
});

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("my@gmail.com"));
message.addRecipients(Message.RecipientType.TO, "yours@gmail.com");
message.setSubject("Subject");
message.setText("Email message!");
Transport.send(message);
bugi
Posts: 7
Joined: Wed Aug 21, 2013 3:33 pm

Re: Unable to send emails from the plugin

Post by bugi »

found the issue, there is a bug in the code that cut part of the receiver's email adress
Fixed that and everything works OK
Thx!
Post Reply