bvstone

Setting Defaults for MAILTOOL and SPLTOOL to use MAILTOOL Plus

Posted:

Setting Defaults for MAILTOOL and SPLTOOL to use MAILTOOL Plus

We're often presented with an issue from customers switching from using the standard MAILTOOL command to using MAILTOOL Plus what the best approach is.

A lot of them have hundreds of programs with the MAILTOOL command in them and changing all of them can be daunting to say the least.

There are really two ways to tackle this:

The Change Command Default (CHGCMDDFT) Command and MAILTOOL Plus Parameters

Well, since MAILTOOL (and SPL2EMAIL if you're using that) are commands, then you can use the good old Change Command Default (CHGCMDDFT) command to change the defaults for the appropriate parameters.  (Of course, if you've hard-coded these in the programs this won't work and you'll need to go through each program and fix things.)

The following command will change the defaults for MAILTOOL (and SPLTOOL) to use MAILTOOL Plus as the default.  If you also require the use of SSL/TLS and/or userid and password, those parameters also can be changed.

//========== MAILTOOL ============

CHGCMDDFTCMD(MAILTOOL) NEWDFT('SENDWITH(*MAILTOOL)')
CHGCMDDFTCMD(MAILTOOL) NEWDFT('MAILRTR(''xx.xx.xx.xx'')')
CHGCMDDFTCMD(MAILTOOL) NEWDFT('USERTR(*ONLY)')

// For Gmail, Office 365, or other servers that require SSL, TLS, And Authentication:
CHGCMDDFT CMD(MAILTOOL) NEWDFT('SSL(*TLS)')  //*YES = SSL, *TLS = TLS
CHGCMDDFT CMD(MAILTOOL) NEWDFT('PORT(587)')  //Normally 465 for SSL or 587 for TLS
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHUSER(''<userid>'')') 
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHOW(''<password>'')')

//========== SPLTOOL ============
CHGCMDDFTCMD(SPL2EMAIL) NEWDFT('SENDWITH(*MAILTOOL)')
CHGCMDDFTCMD(SPL2EMAIL) NEWDFT('MAILRTR(''xx.xx.xx.xx'')')
CHGCMDDFTCMD(SPL2EMAIL) NEWDFT('USERTR(*ONLY)')

CHGCMDDFTCMD(SPL2EMAILB) NEWDFT('SENDWITH(*MAILTOOL)')
CHGCMDDFTCMD(SPL2EMAILB) NEWDFT('MAILRTR(''xx.xx.xx.xx'')')
CHGCMDDFTCMD(SPL2EMAILB) NEWDFT('USERTR(*ONLY)')

// For Gmail, Office 365, or other servers that require SSL, TLS, And Authentication:
CHGCMDDFT CMD(SPL2EMAIL) NEWDFT('SSL(*TLS)')
CHGCMDDFT CMD(SPL2EMAIL) NEWDFT('PORT(587)')
CHGCMDDFT CMD(SPL2EMAIL) NEWDFT('AUTHUSER(''<userid>'')')
CHGCMDDFT CMD(SPL2EMAIL) NEWDFT('AUTHOW(''<password>'')')

CHGCMDDFT CMD(SPL2EMAILB) NEWDFT('SSL(*TLS)')
CHGCMDDFT CMD(SPL2EMAILB) NEWDFT('PORT(587)')
CHGCMDDFT CMD(SPL2EMAILB) NEWDFT('AUTHUSER(''<userid>'')')
CHGCMDDFT CMD(SPL2EMAILB) NEWDFT('AUTHOW(''<password>'')')

Once done, all the commands that don't have SENDWITH, MAILRTR and USERTR defined will now use these new defaults.

One thing to look out for is if you do upgrade versions of MAILTOOL or SPLTOOL, the commands will default back to their original values and these commands will need to be run again.  That's just how things work with IBM commands.

Using Configuration Files and CHGCMDDFT

Another option is to use configuration files to set these values.  You could create a default configuration file to be used and use the CHGCMDDFT command again to the value of that configuration file.

CHGCMDDFT CMD(MAILTOOL) NEWDFT('CONFIG(''/path/myconfigfile.json'')')

CHGCMDDFT CMD(SPL2EMAIL) NEWDFT('CONFIG(''/path/myconfigfile.json'')')

CHGCMDDFT CMD(SPL2EMAILB) NEWDFT('CONFIG(''/path/myconfigfile.json'')')

Now, the configuration file you're using can specify a value in the configuration file for pretty much any other parameter on the command (except the recipients, subject, message and attachments).   This means setting the mail router, send with, use router, smtp user id and password, SSL/TLS settings, etc are all there in a simple JSON file.

In the long run, this is probably the best option as the configuration files really make updating settings for the commands simple and straightforward.

We STRONGLY recommend putting these commands (with the proper values) in a CL so that if you run into issues you can reset these defaults.  

For example, if you install a new version of SPLTOOL or MAILTOOL, this will reset these defaults.  So, after a version update, simply run this command again to reset them to the values required by your organization.

Another example would be if you need to change the from address, authorization user and/or password.  Then you would simply change the values in the CL, compile the CL, and run it so the new values are used. 

 


Last edited 08/17/2020 at 09:14:39




Reply




© Copyright 1983-2024 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).