bvstone

Setting up MAILTOOL to work with Cloud Services such as GMail or Office 365

Posted:

Setting up MAILTOOL to work with Cloud Services such as GMail or Office 365

Many of our customers are making the switch to use GMail, Microsoft (Office 365) or even Yahoo for business as their email provider.  These systems replace older Microsoft Exchange or other in house email solutions.

One issue with this is these cloud services often require more security for the communications, such as authentication with a user id and password and/or SSL or TLS communications.

While the "built in" email API (QtmmSendMail) and commands built around them struggle with SSL and authentication, MAILTOOL (with MAILTOOL Plus) does not, mainly because we ourselves use Google as our email provider and we required a solution for our own applications.

Setting up email to work with these providers can be done one of two ways:

  • Command Interface - This method uses the Change Command Default (CHGCMDDFT) command to set the defaults for the MAILTOOL (and SPL2EMAIL if applicable) parameters that deal with the new mail router
  • Configuration Files - Using configuration files these settings can be also configured globally or on a per user basis.  This is the recommended method which makes updating versions easier.

The information you will need for setup for either case will be as follows:

  • The outgoing SMTP server name.  For GMail it's normally smtp.gmail.com and for Office 365 it's normally smtp.office365.com. 
  • The type of secure connection that is used.  This will normally be either SSL or TLS
  • The port to use.  For SSL this is normally 465 and for TLS 587.
  • Is authentication required?  This means, do you need to specify a user id and password when sending emails?
  • Do you have the appropriace Certificate Authorities (CAs) installed?  If this is your first time setting up, most likely not.  You can download the appropriate CAs and install them following these instructions:

If you're using a PC email client to send emails then all of this information should already be set up in the application.  So that is a good place to start when finding this information.

Command Interface

If you mainly use the MAILTOOL (or SPL2EMAIL/SPL2EMAILB) command then setting things up is as easy as changing the defaults for the appropriate parameters so that your new mail router will use the proper settings.  The Change Command Default (CHGCMDDFT) command is used as follows:

CHGCMDDFT CMD(MAILTOOL) NEWDFT('SENDWITH(*MAILTOOL)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('MAILRTR(smtp.gmail.com)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('USERTR(*ONLY)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('SSL(*YES)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('PORT(465)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHUSER(''<userid>'')) 
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHPW(''<password>'')) 

The above example would be used for GMail.  The following example would be used for Office 365:

CHGCMDDFT CMD(MAILTOOL) NEWDFT('SENDWITH(*MAILTOOL)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('MAILRTR(smtp.office365.com)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('USERTR(*ONLY)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('SSL(*TLS)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('PORT(587)')
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHUSER(''<userid>'')) 
CHGCMDDFT CMD(MAILTOOL) NEWDFT('AUTHPW(''<password>'')) 

Remember to replace <userid> and <password> with the appropriate account information for sending the email.  If the AUTHUSER parameter doesn't match the FROM address you may have issues.  Some systems (like Office 365) lets you set it up so you can send on behalf of another user account, so you will need to set up that if these parameters don't match.

If you are also using SPL2EMAIL you can also run these commands for the SPL2EMAIL and SPL2EMAILB commands.

Configuration Files

With the latest version of MAILTOOL configuration files can be used at the global level or the user level.  

Our advice is to first change the global default configuration file so that the appropriate information is there for the main sender of your email, port and SSL mode and authentication information.  

...

    {
		"name":"send_with_server_type",
		"default":"*MAILTOOL"
	},
	{
		"name":"mail_router",
		"default":"smtp.gmail.com"
	},
	{
		"name":"use_mail_router",
		"default":"*ONLY"
	},
	{
		"name":"use_ssl",
		"default":"*YES"
	},
	{
		"name":"smtp_port",
		"default":"465"
	},
	{
		"name":"from_email",
		"default":"info@wheelerdealers.com"
	},
	{
		"name":"from_name",
		"default":"Wheeler Dealers Info"
	},
	{
		"name":"smtp_auth_user",
		"default":"info@wheelerdealers.com"
	},
	{
		"name":"smtp_auth_password",
		"default":"infopassword1234"
	},
...

Then, when you copy the configuration for new users all that needs to be changed is the from address, from name, user id and password information in their configuration file.   

...
	{
		"name":"from_email",
		"default":"mikebrewer@wheelerdealers.com"
	},
	{
		"name":"from_name",
		"default":"Mike Brewer"
	},	{
		"name":"smtp_auth_user",
		"default":"mikebrewer@wheelerdealers.com"
	},
	{
		"name":"smtp_auth_password",
		"default":"tattyshiftknob"
	},
...

When using configuration files, only one parameter default needs to be changed.  

CHGCMDDFT CMD(MAILTOOL) NEWDFT('CONFIG(*DFT)')  

When using the MAILTOOL (or SPL2EMAIL/SPL2EMAILB) command and specifying *DFT for the configuration file the file that is used will be /bvstools/mailtool/config/userid/defaults.json (where userid is the user's User ID).  If this file doesn't exist, then the supplied default configuration file /bvstools/mailtool/config/defaults.json will be used.  See this article for more information.

Feel free to contact us if you require any extra help or support.


Last edited 01/30/2018 at 12:46:45



Latest Posts:

G4MSDRV Currently Not Supported G4MSDRV Currently Not Supported
Posted by 3 days ago
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
Removing Trailing Carriage Returns and/or Line Feeds from a String with RPG Removing Trailing Carriage Returns and/or Line Feeds from a String with RPG
Posted by December 26, 2018
Programming >> RPG Programming
Create QRCODE in DDS Create QRCODE in DDS
Posted by September 21, 2018
Programming >> RPG Programming
Base64 Encoding a File with RPG Base64 Encoding a File with RPG
Posted by September 6, 2018
Programming >> RPG Programming
Building JSON with RPG and YAJL and Writing to Standard Output Building JSON with RPG and YAJL and Writing to Standard Output
Posted by August 31, 2018
Programming >> Proof of Concept (POC)
How to Delete Files or Empty Trash From Your Google Drive with your IBM i and RPG/ILE How to Delete Files or Empty Trash From Your Google Drive with your IBM i and RPG/ILE
Posted by July 24, 2018
BVSTools >> BVSTools Software Discussion >> GreenTools for G Suite (Google Apps) (G4G) Specific Discussion
GreenTools for G Suite (G4G) Updated to Include Delete and Empty Trash Function GreenTools for G Suite (G4G) Updated to Include Delete and Empty Trash Function
Posted by July 24, 2018
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
What to Do If Your License Keys Don't Work What to Do If Your License Keys Don't Work
Posted by July 18, 2018
BVSTools >> BVSTools Software Discussion
MAILTOOL Updated to Allow Failed Message on Invalid Recipient MAILTOOL Updated to Allow Failed Message on Invalid Recipient
Posted by May 20, 2018
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
Non HTTPS Callbacks Removed from GreenTools for G Suite (G4G) Non HTTPS Callbacks Removed from GreenTools for G Suite (G4G)
Posted by April 15, 2018
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
IBM i Related Survey Available IBM i Related Survey Available
Posted by April 7, 2018
IBM Power Systems >> (QGPL) IBM i
BVSTools Releases Braintree Webhook Open Source Application - Node.js BVSTools Releases Braintree Webhook Open Source Application - Node.js
Posted by April 5, 2018
Programming >> Open Source
BVSTools Now Offering Web Services (BETA) BVSTools Now Offering Web Services (BETA)
Posted by April 3, 2018
BVSTools >> BVSTools Announcements
Creating a Reverse SSL Proxy Using RPG on the IBM i - Part 2 Creating a Reverse SSL Proxy Using RPG on the IBM i - Part 2
Posted by March 29, 2018
Programming >> Web Programming
Still on V7R1 or Earlier?  Here's Why You Should Upgrade NOW! Still on V7R1 or Earlier? Here's Why You Should Upgrade NOW!
Posted by February 21, 2018
IBM Power Systems >> (QGPL) IBM i

Reply




Copyright 1983-2018 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).