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!";


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 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.