ellite/Wallos · critical · Exception
$this->lang('instantiate')
Error message
$this->lang('instantiate') What it means
Thrown by mailSend() when PHP's built-in mail() function returns false, meaning PHP could not even hand the message to the configured mail transfer agent. It is a critical STOP_CRITICAL error with the localized 'instantiate' message. Unlike the SMTP transports, mail() gives no detailed reason, so the error is intentionally terse.
Solutions
- Check php.ini mail configuration: sendmail_path (Linux) or SMTP/smtp_port (Windows) must point to a working MTA.
- Verify the From address is valid and allowed by the host (many hosts require a local domain sender).
- Install/configure an MTA (msmtp, postfix) and set sendmail_path = "/usr/sbin/msmtp -t" if none exists.
- Switch to SMTP transport: $mailer->isSMTP() with host/port/credentials, which gives better diagnostics.
- Confirm mail() is not disabled via disable_functions in php.ini.
Example fix
// before $mailer->isMail(); // mail() returns false: no MTA in container // after $mailer->isSMTP(); $mailer->Host = 'smtp.example.com'; $mailer->SMTPAuth = true; $mailer->Username = 'user@example.com'; $mailer->Password = 'secret'; $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mailer->Port = 587;
Defensive patterns
Strategy: validation
Validate before calling
$path = ini_get('sendmail_path');
if (PHP_SHLIB_SUFFIX === 'so' && (empty($path) || in_array('mail', explode(',', ini_get('disable_functions') ?: '')))) {
// mail() will fail: use SMTP instead
} Try / catch
try {
$mailer->send();
} catch (PHPMailer\PHPMailer\Exception $e) {
if ($e->getMessage() === $mailer->lang('instantiate')) {
error_log('mail() failed: check sendmail_path / MTA; ' . $e->getMessage());
}
} Prevention
- Check php.ini sendmail_path (or Windows SMTP settings) before relying on isMail().
- Confirm mail() is not in disable_functions.
- Install an MTA in the deployment environment or switch to SMTP.
- Ensure the From address is allowed by the host's MTA policy.
When it happens
Trigger: Calling $mailer->send() with isMail() (default transport) when mail() returns false: no sendmail_path configured, mail() disabled (sendmail_path empty or disable_functions), or invalid From header causing immediate rejection.
Common situations: PHP-FPM/Apache containers with no MTA installed and sendmail_path unset, shared hosts blocking mail(), Windows servers without a configured SMTP directive in php.ini, or ini_set('sendmail_from') failures.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13).
Data as JSON: /api/errors/4ad56658e2a8154c.
Report an issue: GitHub.
Appendix: source
Thrown at libs/PHPMailer/PHPMailer.php:1970
$result,
[[$addrinfo['address'], $addrinfo['name']]],
$this->cc,
$this->bcc,
$this->Subject,
$body,
$this->From,
[]
);
}
} else {
$result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
$this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$result) {
throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
/**
* Get an instance to use for SMTP operations.
* Override this function to load your own SMTP implementation,
* or set one with setSMTPInstance.
*
* @return SMTP
*/
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
$this->smtp = new SMTP();
}
View on GitHub (pinned to 52820e87ca)