In this article we outline a way to implement PHPMailer to send emails from the IBM i. The emails can have attachments such as pdf’s and can be sent with SSL/TLS encryption.

The PHPMailer software runs using PHP on the IBM i. It does not need a webserver to be running just that PHP is loaded on the IBM i. We are using Community PHP where the Command Line Interface (CLI) program runs from /QOpenSys/pkgs/bin/php. For Zend PHP Enterprise and Basic running from ZENDPHP7 the CLI is found at /usr/local/zendphp7/bin/php-cli.

From an SSH terminal session (We used the one in IBM Access Client Solutions – ACS) the command to download the PHPMailer open source software is: wget –no-check-certificate https://github.com/PHPMailer/PHPMailer/archive/master.zip
We are using the no-check-certificate option to bypass the certificate check (Use with caution). We have installed the software to /QOpenSys/pkgs/lib. Use unzip to extract from the downloaded master.zip file.

IBM i Access Client Solutions, SSH Terminal

IBM i Access Client Solutions, SSH Terminal


The IBM i Access Client Solutions page can be found at IBM i Access Client Solutions – Main Suport Page

Rename the PHPMailer-master directory to PHPMailer once extracted.

PHPMailer caters for SMTP Authentication with SSL/TLS with multiple attachments and HTML formatted body text.

The PHP script we have setup to run PHPMailer is called from a CL program using QP2SHELL.

See the example programs and PHP script for information on how to use PHPMailer

All the example scripts and programs used in the video are available to be downloaded at this link address using PHPMailer on the IBM i

Here is the link to the main PHPMailer page on github: https://github.com/PHPMailer/PHPMailer

See a video showing outlining the detail steps we took to download and install the PHPMailer software. The video also shows the CL command and program and the PHP script we created in order to invoke the PHPMailer script. Here is a link to the youtube video: https://youtu.be/y8EcCV7yZ-0

/* All source code attached to this document are provided on an “AS IS” basis without warranty of any kind. NOVAGEM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES INCLUDING LOST PROFITS OR SAVINGS. */