Problem

Following a fresh install of Zend Server 2018 (PHP7.2.1) php mail stopped working.
The following message is given in the  Apache HTTPD log file www\zendphp7\logs\error_log.Q_date_time_stamp:
sh: /usr/sbin/sendmail: not found

Possible cause when the Zend Server libraries deployed are not updated to the latest versions available.
IBM i not connected to the web,(no internet access).


Solution

Download and deploy the latest Zend Framework Libraries.
Use the SMTP Transport found in Zend Framework a more reliable and easy to implement.

In the following article you can find an examples written for Zend Framework 1 and Zend Framework 2.

Use Framework's SMTP Transport instead of mail() on IBM i

Use Zend Framework SMTP Transport instead of mail() on IBM i

Replace some values in the examples

In the following examples, we have used some dummy values that can be replaced with the real values for the mail to be sent.  We specified 'mail.example.com' as the mail server, '[email protected]' as the email of the person sending the email, '[email protected]' as the email of the person to receive the email, 'TestSubject' as the subject line of the email, and 'This is the text of the mail.' as the text for the email.  We suggest creating a simple test script with just these values replaced with some real values, to verify that you can send a simple email.  Then, you can visit the reference links provided to learn how to do more, like add recipients, include attachments, authentication, and so on.

Adjust your paths to use earlier versions

The path to Zend Server 2021 begins with /usr/local/zendphp74.  For versions 9 and 2019, you should change zendphp74 to zendphp7.  For versions 6 to 8.5, you should change zendphp74 to zendsvr6.

Framework 1 example script:

<?php

ini_set('include_path',ini_get('include_path').':/usr/local/zendphp74/var/libraries/ZendFramework_1/');
require_once('Zend/Mail.php');
require_once 'Zend/Mail/Transport/Smtp.php';

$tr = new Zend_Mail_Transport_Smtp('mail.example.com');
Zend_Mail::setDefaultTransport($tr);

$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send();
?>

The above example assumes you have the Framework directory in your include path, which is a default for Zend Server.  If needed, please add a line to include Framework in the path:

ini_set('include_path',ini_get('include_path').':/usr/local/zendphp74/var/libraries/ZendFramework_1/');

References:
Introduction - Zend_Mail (ZF 1.12)
Sending via SMTP - Zend_Mail (ZF 1.12)


Framework 2 example script:

<?php

//ini_set('include_path', '/usr/local/zendphp74/share/ZendFramework2/library'); 
ini_set('include_path', ini_get('include_path').':/usr/local/zendphp74/var/libraries/Zend_Framework_2/default/library');  
require_once 'Zend/Loader/StandardAutoloader.php';

$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();

use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;

// Important: Code above this comment must be placed in the outermost scope of the file, preferably right at the top.
// Code below this comment may be placed in a function, provided the function runs after the "use" statements have completed.

$message = new Message();
$message->addTo('[email protected]')
        ->addFrom('[email protected]')
        ->setSubject('TestSubject')
        ->setBody("This is the text of the mail.");

// Setup SMTP transport
$transport = new SmtpTransport();
$options   = new SmtpOptions(array(
    'name' => 'example.com',
    'host' => 'mail.example.com',
    'port' => 25,
));
$transport->setOptions($options);
$transport->send($message);
?> 

References:
Zend\Mail\Transport — Zend Framework 2 2.4
Zend\Mail\Transport\SmtpOptions — Zend Framework 2 2.4

Zend Mail SMTP Options

Use Framework's SMTP Transport instead of mail on IBM-i

IBM i SMTP Mail -The PHP mail Function-

Zend Server Libraries

Zend Framework downloads

Create .zpks the easy way