Well I would certainly activate debug - that should help - see my example below.

I don't see where you have set the host - have you used the config for that?

Anyway - here's a working example from my system.

* This example shows sending a message using a local sendmail binary.

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

require 'PHPMailerAutoload.php';

// Create a new PHPMailer instance
$mail = new PHPMailer;

// Set PHPMailer to use the SMTP transport

// Set debug to verbose
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';

// Set authorization required and host location
$mail->SMTPAuth = true;

$mail->Host = 'tls://smtp.gmail.com:587';

$mail->Username = 'fred@xxxxxxx'; // SMTP account username
$mail->Password = "fredspw"; // SMTP account password

// Set who the message is to be sent from
$mail->setFrom('SiD@xxxxxxxxxxxxxxxxxxxx', 'RPG & DB2 Summit Exhibitors');

// Set who the message is to be sent to
$mail->addAddress('Jon.f.Paris@xxxxxxxxx', 'Jon gmail');

// Set the subject line
$mail->Subject = 'Testing email password';

// Read an HTML message body from an external file, convert referenced images to embedded,
// convert HTML into a basic plain-text alternative body
$mail->msgHTML( '<html><body>Simple <b>HTML</b> email message Sent from Jons Mac using SiD account');

// Replace the plain text body with one created manually
$mail->AltBody = 'Simple plain text alternative';

// send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";

Jon Paris


On Sep 17, 2018, at 6:17 PM, Steve Richter <stephenrichter@xxxxxxxxx> wrote:

need advice on how to correctly use PHPMailer on IBM i. When sending a
simple text email message, get error Mailer Error: Could not instantiate
mail function.

no messages in the php.log

I am able to send email using the PHP mail( ) function. So I assume the
sender email is correct.

I did not use composer to install PHPMailer. To install I went to github
and got the phpmailer directory. Then copied to

Then I run some basic PHP code to send an email. I am able to new up the
PHPMailer object. But I get the "could not instantiate" error on the ->send


use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require '/usr/local/zendphp7/share/php-mailer/src/Exception.php';
require '/usr/local/zendphp7/share/php-mailer/src/PHPMailer.php';
require '/usr/local/zendphp7/share/php-mailer/src/SMTP.php';

// Include and initialize phpmailer class
// require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

echo '<h1>hello</h1>';

//Set who the message is to be sent from
$mail->setFrom('me@xxxxxxxxxx', 'xxx');

//Set who the message is to be sent to
$mail->addAddress('stephenrichter@xxxxxxxxx', 'Steve Richter');

//Set the subject line
$mail->Subject = 'PHPMailer mail() test';

$mail->Body = 'This is a plain-text message body';

echo '<p>message prepared</p>' ;

//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";

This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.