Are you using the JavaMail jar file and a Java or RPG program ?

I guess if you're using RUNJVA you're creating a Java program.

First I would never use RUNJVA. Use something like the QSH command to run your Java or something like the QSHEXEC command in my QShell on I open source utility. You can then actually capture a Java return code error as well as STDOUT which is Java command line logging.

Word has it that Basic Auth is going away in 2026 so you may want to actually start looking in to using MS Graph and OAuth2. Or you could look into creating an Exchange SMTP Connector which will allow your team to use port 25 to still send unauthenticated emails via TLS on Port 25 from your public IP address. There is some Office365 config required as well as you need to create an Exchange Connector.

Might want to upgrade your Java version unless you're on an old IBMi. Minimally 1.8 would be a good idea.

Regards,
Richard Schoen
Web: http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx

-----Original Message-----
Today's Topics:
1. Java Apache to Office 365 (Versfelt, Charles via JAVA400-L)

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

message: 1
date: Mon, 17 Nov 2025 18:23:01 +0000
from: "Versfelt, Charles via JAVA400-L" <java400-l@xxxxxxxxxxxxxxxxxx>
subject: Java Apache to Office 365

Hi,
I'm fairly inexperienced in java, I'm mainly an old-school RPG programmer.
We have several Java programs that send e-mails, some with and some without attachments, using Apache commons.
I'm somewhat familiar with the programs. Our IBMi is on java version "1.6.0"

We're switching our e-mail to office 365.
I've gone through the same change with a number of Visual Basic programs, and now I'm trying to address the IBMi Java programs.

The changes I had to make in my Visual Basic programs are these:
1. The host has to change to smtp.office365.com 2. SSL has to be enabled.
3. The port used has to be 587.
4. I have to force TSL 1.2 security level.
In Visual Basic, to force TSL 1.2, I had to use command ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

From the searching I did online, I found some websites talking about sending office 365 e-mails in Java, but not a lot specific to Apache Commons.
As I said, I don't want to rewrite the programs if I can avoid it.

As far as I can tell from what I saw online, if all I need is what I changed in my VB.net programs, I can change these in my Apache Commons Java E-mail programs like this:
1. email.setHostName("smtp.office365.com");
2. email.setSSLOnConnect(true);
3. email.setSmtpPort(587);

4. System.setProperty("mail.transport.protocol", "smtps"); System.setProperty("mail.smtps.ssl.protocols", "TLSv1.2");

So my program looks like this, passwords and e-mails masked.

HtmlEmail email = new HtmlEmail ();

//email.setHostName("exchange.postoffice.net");
System.setProperty("mail.transport.protocol", "smtps"); System.setProperty("mail.smtps.ssl.protocols", "TLSv1.2"); email.setHostName("smtp.office365.com");
email.setSmtpPort(587);
email.setSSLOnConnect(true);
(everything below is original)
try {
email.setFrom("xxx@xxxxxxx", "Me");
email.setAuthenticator(new DefaultAuthenticator("xxx@xxxxxxx" "xxx")); } catch (EmailException e1) { CleanUp(); } When I test this program from the command line RUNJVA, the program says Java program completed, but no e-mail arrives.
As far as I can tell it's not encountering any errors. It's just not sending an e-mail.
Am I missing something?

Thanks for your help.
Charles Versfelt


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.