Hi,

I tried it with Tomcat 10 (10.1.31 to be exact) and for the Jakarta
Mail I added to the lib folder the jakarta.mail-api-2.1.3.jar,
jakarta.activation-api-2.1.3.jar and angus-mail-2.0.3.jar.

It works if I create the Session object programmatically:

            Properties props = new Properties();
            props.put("mail.smtp.starttls.enable", "true");
            props.put("mail.smtp.host",
"smtp.email.eu-frankfurt-1.oci.oraclecloud.com");
            props.put("mail.smtp.port", "587");
            props.put("mail.from", "f...@email.com");
            props.put("mail.smtp.auth", "true");
            String username = "ocid1.user.oc1...com";
            String password = "password";

            session = Session.getInstance(props, new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });

But I was trying to have it configured by Tomcat and use JDNI to get
the Session.

Regards,
Ricardo Almeida

On Tue, 26 Nov 2024 at 09:17, Zdeněk Henek <vrab...@gmail.com> wrote:
>
> Hi Ricardo,
>
> Could you provide what Tomcat version you use?
> Is it possible you use Tomcat 9 and you should use library using javax.mail
> api instead of library based on new jakarta namespace?
>
> Regards,
> Zdenek Henek
>
> On Tue, Nov 26, 2024 at 8:43 AM Ricardo Almeida <ric.alme...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I'm trying to configure Jakarta Mail using JNDI but it seems there's
> > some issue setting up the parameters Tomcat should pass on to Jakarta
> > Mail.
> >
> > I configured it using:
> >
> >     <Resource
> >         global="mail/Session"
> >         name="mail/Session"
> >         auth="Container"
> >         type="jakarta.mail.Session"
> >     />
> >     <ResourceParams name="mail/Session">
> >         <parameter>
> >             <name>mail.smtp.starttls.enable</name><value>true</value>
> >         </parameter>
> >         <parameter>
> >             <name>mail.smtp.host</name><value>
> > smtp.email.eu-frankfurt-1.oci.oraclecloud.com</value>
> >         </parameter>
> >         <parameter>
> >           <name>mail.smtp.port</name><value>587</value>
> >         </parameter>
> >         <parameter>
> >           <name>mail.from</name><value>f...@email.com</value>
> >         </parameter>
> >         <parameter>
> >           <name>mail.smtp.auth</name><value>true</value>
> >         </parameter>
> >         <parameter>
> >           <name>mail.smtp.user</name><value>ocid1.user.oc1...com</value>
> >         </parameter>
> >         <parameter>
> >           <name>password</name><value>password</value>
> >         </parameter>
> >     </ResourceParams>
> >
> > But, I got Exception trying to connect to localhost port 25, instead
> > of the parameters set!
> >
> > Caused by: org.eclipse.angus.mail.util.MailConnectException: Couldn't
> > connect to host, port: localhost, 25; timeout -1
> >     at
> > org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2243)
> > ~[angus-mail-2.0.3.jar:?]
> >     at
> > org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:729)
> > ~[angus-mail-2.0.3.jar:?]
> >     at jakarta.mail.Service.connect(Service.java:345)
> > ~[jakarta.mail-api-2.1.3.jar:?]
> >
> > Any idea what I'm doing wrong?
> >
> > Regards,
> > Ricardo Almeida
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to