bvstone

MAILTOOL v7 Integrates Easy to use ILE Functions and Configuration Files - Send Email from your IBM i (AS/400)

Posted:

MAILTOOL v7 Integrates Easy to use ILE Functions and Configuration Files - Send Email from your IBM i (AS/400)

The latest update to our MAILTOOL Software includes two major updates to make the software even more functional as useful:

ILE Functions
MAILTOOL now has ILE functions available that make sending emails from ILE Programs simple, compared to the past when building a command and calling QCMDEXC was required.  This means sending an email is as simple as the following few lines of code:

 /COPY QCOPYSRC,P.MAILTOOL                                                   

 /free
  if (#mailtool_init() >= 0);   
    #mailtool_setValue('from_email':'publisher@booksrus.com'); 
    #mailtool_setValue('subject':'test email');
    #mailtool_setValue('message':'this is the message nn newline.');  
    #mailtool_addTORecipient('james@thegiantpeach.com'); 
    #mailtool_addAttachment('/myfiles/pdfs/salesreport.pdf');
    #mailtool_sendMail();   
  endif;                
                        
  *INLR = *ON;          
                        
 /end-free 

See this article if you're needing assistance compiling your program to use the F.MAILTOOL ILE Service Program.

 

Configuration Files
Configuration Files are now used to set the values of most parameters and values of a MAILTOOL call, either from the command (when *DFT or a configuration file is specified) or from the ILE functions (when a configuration file is specified).

When using the MAILTOOL 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.

This can be used to set default values such as the mail server to use, the FROM address, subject, as well as a host of other values.  

The configuration files are standard JSON files so a simple text editor is all that is needed to change the values.

When using the MAILTOOL command you can also override all the parameters (except for the TO, CC, BCC, Subject, Message and Attachment parameters) by specifying a configuration file to use on the MAILTOOL command.  

MAILTOOL TOADDR('bvstone@bvstools.com') 
SUBJECT('Testing config file') 
MESSAGE('This is a test of the config file') 
CONFIG('/bvstools/mailtool/config/myconfig.json')

The From address, as well as any other parameters (such as SENDWITH, MAILRTR, USERTR, SSL, DEBUG, etc) will use the values in the Configuration file specified. 

If a configuration file is used with the MAILTOOL command, the parameters on the MAILTOOL command will be overridden with the values from the configuration file EXCEPT for the recipients (TO, CC and BCC) and Attachments or if the value of the default is blank or doesn't exist in the configuration file used.

This ability has also been added to the SPL2EMAIL and SPL2EMAILB commands for compatibility.

Configuration Files can also be used in the ILE functions.  The only difference is any of the values that once the #mailtool_loadDefaults() function is called any values in the configuration file will override any values already set by #mailtool_setValue().  The opposite is also true, so be sure to do things in the correct order for your project.

 /COPY QCOPYSRC,P.MAILTOOL                                                   

 /free                                                                       
  if (#mailtool_init() >= 0);                                                
    #mailtool_setValue('configuration_file':'/bvstools/mailtool/config/myconfig.json');
    #mailtool_loadDefaults();
    #mailtool_addTORecipient('james@thegiantpeach.com');                      
    #mailtool_sendMail();   
  endif;                
                        
  *INLR = *ON;          
                        
 /end-free 

In this example the only value we are setting is the TO address.  Everything else, including the FROM address, Subject and Message are set using the values in the configuration file.

So, what does one of these configuration files look like?  Here's an example of the one that is shipped with MAILTOOL:

{
	"variables": [
	{
		"name":"from_email",
		"default":" "
	},
	{
		"name":"from_name",
		"default":" "
	},
	{
		"name":"subject",
		"default":" "
	},
	{
		"name":"message",
		"default":" "
	},
	{
		"name":"reply_to_email",
		"default":" "
	},
	{
		"name":"reply_to_name",
		"default":" "
	},
	{
		"name":"mdn_email",
		"default":" "
	},
	{
		"name":"mdn_name",
		"default":" "
	},
	{
		"name":"sender_email",
		"default":" "
	},
	{
		"name":"sender_name",
		"default":" "
	},
	{
		"name":"footer_stream_file",
		"default":" "
	},
	{
		"name":"message_id",
		"default":" "
	},
	{
		"name":"message_id_domain",
		"default":" "
	},
	{
		"name":"send_with_server_type",
		"default":"*IBMSMTP"
	},
	{
		"name":"mail_router",
		"default":"*NONE"
	},
	{
		"name":"use_mail_router",
		"default":"*NO"
	},
	{
		"name":"perform_mx_lookup",
		"default":"*YES"
	},
	{
		"name":"use_ssl",
		"default":"*NO"
	},
	{
		"name":"smtp_port",
		"default":"25"
	},
	{
		"name":"smtp_auth_user",
		"default":" "
	},
	{
		"name":"smtp_auth_password",
		"default":" "
	},
	{
		"name":"bind_to_ip_address",
		"default":" "
	},
	{
		"name":"timeout",
		"default":"30"
	},
	{
		"name":"ccsid",
		"default":"819"
	},
	{
		"name":"no_attachment_action",
		"default":" "
	},
	{
		"name":"body_content_type",
		"default":"text/plain"
	},
	{
		"name":"mime_ccsid",
		"default":"819"
	},
	{
		"name":"temporary_directory",
		"default":"/tmp"
	},
	{
		"name":"importance",
		"default":"normal"
	},
	{
		"name":"priority",
		"default":" "
	},
	{
		"name":"recipient_separator",
		"default":","
	},
	{
		"name":"close_connection",
		"default":"*YES"
	},
	{
		"name":"save_email",
		"default":"*DFT"
	},
	{
		"name":"debug",
		"default":"*NO"
	},
	{
		"name":"debug_file",
		"default":"mailtooldebug_/%id%/.txt"
	},
	{
		"name":"debug_smtp_file",
		"default":"mailtoolsmtp_/%id%/.txt"
	}
	]
}

As you can see, the values are simple name/value pairs that can be easily edited and copied!

More information can be found in the MAILTOOL documentation at http://docs.bvstools.com.

MAILTOOL can be downloaded from http://www.bvstools.com/mailtool.html


Last edited 08/20/2015 at 15:08:40



Latest Posts:

GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality GreenTools For G Suite (G4G) v12.00 Released With Base OAuth 2.0 Functionality
Posted by July 28, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
BVSTools Small Price Increase in 2020 BVSTools Small Price Increase in 2020
Posted by July 26, 2019
BVSTools >> BVSTools Announcements
GreenTools for Vertex Cloud (VTXCLOUD) Now Available GreenTools for Vertex Cloud (VTXCLOUD) Now Available
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Vertex Cloud (VTXCLOUD) Specific Announcements
GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google GreenTools for Google Apps (G4G) - Drive Addon Successfully Verified by Google
Posted by July 22, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application
Posted by July 17, 2019
IBM Power Systems >> (QGPL) IBM i
Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product) Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product)
Posted by July 13, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Reading JSON Data from Standard Input With YAJL and RPG Reading JSON Data from Standard Input With YAJL and RPG
Posted by July 12, 2019
Programming >> Proof of Concept (POC)
MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications
Posted by June 19, 2019
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI) GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI)
Posted by June 11, 2019
BVSTools >> BVSTools Announcements >> Get URI (GETURI) Specific Announcements
BVSTools Now Offers Vertex Cloud Interface BVSTools Now Offers Vertex Cloud Interface
Posted by April 15, 2019
BVSTools >> BVSTools Announcements
Token Has an Invalid Signature Error for Office 365 Email Token Has an Invalid Signature Error for Office 365 Email
Posted by March 22, 2019
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
Resending Emails that have Errored Out with Updated Router or Authentication Information Resending Emails that have Errored Out with Updated Router or Authentication Information
Posted by March 1, 2019
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i
Posted by January 27, 2019
BVSTools >> BVSTools Announcements
G4MSDRV Currently Not Supported G4MSDRV Currently Not Supported
Posted by January 17, 2019
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

Reply




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