[ 
https://issues.apache.org/jira/browse/TOMEE-1697?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tamás Greguss updated TOMEE-1697:
---------------------------------
    Description: 
Sending email fails. javamail's Transport.send(...) function throws an 
exception. The same code works fine with previous versions of TomEE which 
includes javamail 1.8.3. But TomEE 1.7.3 upgraded to javamail 1.9.0-alpha2 
which does not work well.
If in TomEE 1.7.3 lib folder I change the content of 
geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar file to the previous 
geronimo-javamail_1.4_mail-1.8.3.jar, it also works well.

Here is the code that works fine with sendmail 1.8.3 in TomEE 1.7.1 but fails 
with sendmail.1.9.0-alpha2 in TomEE 1.7.3:

public static void SendWithGMailSSL( String email_to, String subject, String 
text, String email_from, final String senderuser, final String senderpass ) {

                Properties props = new Properties();
                props.put("mail.smtp.host", "smtp.gmail.com");
                props.put("mail.smtp.socketFactory.port", "465");
                props.put("mail.smtp.socketFactory.class", 
"javax.net.ssl.SSLSocketFactory");
                props.put("mail.smtp.auth", "true");
                props.put("mail.smtp.port", "465");

                Session session;
                try {
                        session = Session.getInstance(props, new 
javax.mail.Authenticator() {
                                @Override
                                protected PasswordAuthentication 
getPasswordAuthentication() {
                                        return new 
PasswordAuthentication(senderuser, senderpass);
                                }
                        });

                } catch (Exception e) {
                        throw new RuntimeException(e);
                }

                try {

                        Message message = new MimeMessage(session);
                        message.setFrom(new InternetAddress(email_from));
                        message.setRecipients(Message.RecipientType.TO, 
InternetAddress.parse(email_to));
                        message.setSubject(subject);
                        message.setText(text);

                        Transport.send(message);

                        //System.out.println("e-mail sending done.");
                } catch (MessagingException e) {
                        throw new RuntimeException(e);
                }
}






  was:
Sending email fails. javamail's Transport.send(...) function throws an 
exception. The same code works fine with previous versions of TomEE which 
includes javamail 1.8.3. But TomEE 1.7.3 upgraded to javamail 1.9.0-alpha2 
which does not work well.
If in TomEE 1.7.3 lib folder I change the content of 
geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar file to the previous 
geronimo-javamail_1.4_mail-1.8.3.jar, it also works well.



> javamail: sending email fails
> -----------------------------
>
>                 Key: TOMEE-1697
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1697
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.7.3
>         Environment: Linux (Ubuntu 14.04.3 LTS), Oracle Java 1.8.0_66
>            Reporter: Tamás Greguss
>            Priority: Critical
>             Fix For: 1.7.4
>
>
> Sending email fails. javamail's Transport.send(...) function throws an 
> exception. The same code works fine with previous versions of TomEE which 
> includes javamail 1.8.3. But TomEE 1.7.3 upgraded to javamail 1.9.0-alpha2 
> which does not work well.
> If in TomEE 1.7.3 lib folder I change the content of 
> geronimo-javamail_1.4_mail-1.9.0-alpha-2.jar file to the previous 
> geronimo-javamail_1.4_mail-1.8.3.jar, it also works well.
> Here is the code that works fine with sendmail 1.8.3 in TomEE 1.7.1 but fails 
> with sendmail.1.9.0-alpha2 in TomEE 1.7.3:
> public static void SendWithGMailSSL( String email_to, String subject, String 
> text, String email_from, final String senderuser, final String senderpass ) {
>               Properties props = new Properties();
>               props.put("mail.smtp.host", "smtp.gmail.com");
>               props.put("mail.smtp.socketFactory.port", "465");
>               props.put("mail.smtp.socketFactory.class", 
> "javax.net.ssl.SSLSocketFactory");
>               props.put("mail.smtp.auth", "true");
>               props.put("mail.smtp.port", "465");
>               Session session;
>               try {
>                       session = Session.getInstance(props, new 
> javax.mail.Authenticator() {
>                               @Override
>                               protected PasswordAuthentication 
> getPasswordAuthentication() {
>                                       return new 
> PasswordAuthentication(senderuser, senderpass);
>                               }
>                       });
>               } catch (Exception e) {
>                       throw new RuntimeException(e);
>               }
>               try {
>                       Message message = new MimeMessage(session);
>                       message.setFrom(new InternetAddress(email_from));
>                       message.setRecipients(Message.RecipientType.TO, 
> InternetAddress.parse(email_to));
>                       message.setSubject(subject);
>                       message.setText(text);
>                       Transport.send(message);
>                       //System.out.println("e-mail sending done.");
>               } catch (MessagingException e) {
>                       throw new RuntimeException(e);
>               }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to