× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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
/usr/local/zendphp7/share/php-mailer.

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

<?php

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-Ups:

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

This mailing list archive is Copyright 1997-2024 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.