cancel
Showing results for 
Search instead for 
Did you mean: 

SMTP Server with authentification

RenaldWittwer
Contributor
0 Kudos

Hello,

I try to develop a programm that sends emails. I use the javamail-api and analysed the JavaMail-tutorial.

I use the following code to get the session:

props.put( "domain", "true" );

Context initialContext = new InitialContext( props );

Session session = ( Session )initialContext.lookup( "java:comp/env/mail/MailSession" );

I changed the smtp-server in the administration of the j2ee-server.

Everything works fine as long as I use a smtp-server without authentification. Unfortunally (or thanks good?) my productive smtp-server works with authentification.

Has anybody an idea how to handle this problem?

Thanks for help!

Best regards

Renald

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello. I know you face this problem some years ago, I face it like 2 months ago !!

some people might still looking for an answer, so this is what I think:

You can send mails using the samples we all find here (sdn.sap.com), they work fine if your mail server is smtp.

But when you need authentication, you might be talking about smtps. Thats smtp with ssl.

For instance, those examples does not work with gmail.

see this this properties:

Visual Admin Tool -> Services -> JavaMail client -> properties.

Config Tool -> menu choose File -> Configuration Editor -> Configurations -> cluster_data -> server -> META-INF -> javamail.default.providers

There is no smtps property. And if you find the jar that is useed for mailing, you will see that it does not has a class for smtps.

Finally a google for some jar with smtps support and use it in my projects.

The jar: jsse.jar. Also dont forget to add the additional librarie "mail" to the project. You might need it too.

An other thing, this jar is found in:

Visual Admin tool -> Services -> JMS Connector -> Runtime -> JMS Libraries -> jsse.

I wonder if it can be used some how with JMS.

RenaldWittwer
Contributor
0 Kudos

Hello Gregor,

yes I know Google and I found a lot of Sites describing how SMTP and authentification works.

I tried a lot of these examples. If I run these examples direct, they work. But if I run these examples on the SAP J2EE they don't work, probably because there are some special things with the Javamail-Client on the SAP J2EE-Engine.

Example:

In all these examples they use a statement like this to get the session:

session = Session.getDefaultInstance(props, <b>auth</b>);

This statment doesn't work in a webdynpro or webservice programm running on the SAP J2EEE engine. So I use the following statement as given in tutorials and in this forum:

Context initialContext = new InitialContext(props);

Session session =(Session) initialContext.lookup("java:comp/env/mail/MailSession");

How can I give the authentification (auth)?

Best regards

Renald

gregorw
Active Contributor
0 Kudos

Hello Renald,

do you know Google ? I found this .

Regards

Gregor