In March 2026, Microsoft will be removing User/Password BASIC authentication from their email services. This will force users to use a "more secure method" such as OAuth 2.0.
MAILTOOL has had the option to use OAuth 2.0 authentication for Office 365 and GMail for over 10 years now by utilizing the GreenTools for Microsoft Apps (G4MS) or GreenTools for G Suite (G4G), respectively.
With this change rapidly approaching, many customers and non-customers have contacted us to see if we have a soluting for using either SNDDST, SNDSMTPEMM, or even "roll your own" applications that call the QtmmSendEMail API.
The answer is Yes!
If you are using the SNDDST and/or SNDSMTPEMM commands and require updating your authentication with Microsoft Offic 365 to use OAuth 2.0, you can easily override this command to use MAILTOOL in the background with a few easy steps. (In the future Google will probably require this for GMail as well, but the process will be very similar).
Download and install eMail Tool (MAILTOOL) and GreenTools for Microsoft Apps (G4MS). Download instructions are in the readme.txt file of each of the downloaded ZIP files. If you need assistance FTPing the save files to your IBM i, please see the BVSTools FAQ for an example.
Request temporary keys for MAILTOOL and G4MS using the Quick Key feature at BVSTools.
Apply keys for the required packages (MAILTOOL, G4MS, G4MSMAIL and GETURI). When you request a key for G4MS, you will get temporary keys for everything required in that package (G4MS, G4MSMAIL and GETURI). GETURI, while also a standalone product available, is also included in the G4MS library.
Register each account you are sending email from with using the Register Service (G4MSREGSVC) command. Here's a video showing the process. More info can be found in this article.
Choose which method you will want to use to override the SNDDST and/or SNDSMTPEMM command. This will be renaming the existing IBM command objects so that the commands in the MAILTOOL library will be used:
Change the processing program for the SNDDST command to be SNDDSTRG (which is a program in the MAILTOOL library).
CHGCMD CMD(QSYS/SNDDST) PGM(*LIBL/SNDDSTRG)
or rename the SNDDST command object to SNDDSTX so that when SNDDST is called, the version of the command in the MAILTOOL library will be used.
RNMOBJ OBJ(QSYS/SNDDST) OBJTYPE(*CMD) NEWOBJ(SNDDSTX)
or
Prefix SNDDST command with the MAILTOOL library when calling it in your applications:
MAILTOOL/SNDDST
Rename the SNDSMTPEMM command objects to SNDSMTPEMX so that when SNDSMTPEMM is called, the version of the command in the MAILTOOL library will be used.
RNMOBJ OBJ(QSYS/SNDSMTPEMM) OBJTYPE(*CMD) NEWOBJ(SNDSMTPEMX)
RNMOBJ OBJ(QTCP/SNDSMTPEMM) OBJTYPE(*CMD) NEWOBJ(SNDSMTPEMX)
or
Prefix the SNDSMTPEMM with the MAILTOOL library:
MAILTOOL/SNDSMTPEMM
NOTE: Whichever method you choose, you will need to periodically check that these objects are still renamed or the processing program is still changed to use the MAILTOOL program. This is because these are system commands and applying PTFs, installing a new IBM i OS version, or other things may reset these back to "factory".
Set up your MAILTOOL Configuration file in the /bvstools/mailtool/config directory named defaults.json. It can be as simple as this:
{"variables":
[
{"name":"send_with_server_type","default":"*G4MSMAIL"}
]
}
I would suggest setting it up so that you can easily turn debug on or off quickly and easily with a configuration file like this:
{"variables":
[
{"name":"send_with_server_type","default":"*G4MSMAIL"},
{"name":"debug","default":"*NO"},
{"name":"debug_file","default":"mailtooldebug_/%id%/.txt"},
{"name":"debug_smtp_file","default":"mailtoolsmtp_/%id%/.txt"}
]
}
With these extra debug options, just change the "debug" value from "*NO" to "*YES" and debug files will be created automatically. These come in handy when you need support with MAILTOOL.
See this article for more details on what we need to help with issues you may have.
See this article for more detailed info on how configuration files work, and how you can set up specific configuration files by User ID, should that be needed.
In the /bvstools/mailtool/config directory there should also be a file named defaults_example.json that has other available parameters you can override. You can also see this MAILTOOL documentation for values that are "settable" and what they do.
Check the value of the data area named SDCONFIG in the MAILTOOL library. It should come set as *DFT (which means it will first look for a config file set up specifically for the user running the command (ie, /bvstools/mailtool/config/[USERID]/defaults.json), and if that isn't found it will use /bvstools/mailtool/config/defaults.json), but if you create a configuration file in the IFS that you wish to use instead of the default, just specify the fully qualified path to the file in this data area.
Make sure that each user that will be sending email is set up in the Work With Directory Entry (WRKDIRE) command and that they have an SMTP address set up using option F19 in WRKDIRE.
Add MAILTOOL and G4MS to your library list.
Try the SNDDST or SNDSMTPEMM command!
A lot of shops also wrote their own email programs that call the QtmmSendMail API. These programs will also be affected by this change from Microsoft.
With MAILTOOL and G4MS, there is also the option to use the MIME file that your program is already using. But, instead of calling the QtmmSendMail API you would use MAILTOOL and/or G4MS ILE functions. For example:
**FREE
ctl-opt DFTACTGRP(*NO) BNDDIR('BVSTOOLS');
/COPY QCOPYSRC,P.MAILTOOL
dcl-s errMsg char(256);
dcl-s rc int(10);
dcl-s msgid zoned(13:0);
//Create your MIME file
//Call the MAILTOOL ILE Functions to assign the MIME file to the email and send it
if (mailtool_init() >= 0);
rc = mailtool_setValue('from_email':'youremailaddress@yourdomain.com');
rc = mailtool_setValue('send_with_server_type':'*G4MSMAIL');
rc = mailtool_setValue('mime_file':'/tmp/myMimeFile.txt');
rc = mailtool_sendMail(errMsg:msgid);
endif;
*INLR = *ON;
See this article for more information.
Feel free to contact us with any questions, comments, or inquiries!