ellite/Wallos · critical · Exception
$this->ErrorInfo
Error message
$this->ErrorInfo
What it means
Thrown in smtpSend() when the SMTP server rejects the MAIL FROM envelope sender ($this->Sender, falling back to $this->From). PHPMailer first records a detailed error via setError() (localized 'from_failed' plus the address and the SMTP error), then rethrows it as $this->ErrorInfo as a critical exception. The recipient-side SMTP error text is embedded in ErrorInfo.
Solutions
- Check $mailer->ErrorInfo for the exact SMTP reply and fix the From address accordingly.
- Set From to an address the authenticated SMTP user is allowed to send as (the account itself or a verified alias/sendas).
- Ensure From is a valid RFC address and set Sender/envelope-from explicitly if different: $mailer->Sender = 'bounce@example.com'.
- Configure SPF/DKIM/DMARC for the sending domain if the server enforces alignment.
- Inspect the server with SMTPDebug = DEBUG_SERVER to see the raw rejection code.
Example fix
// before $mailer->isSMTP(); $mailer->Username = 'noreply@example.com'; $mailer->From = 'someone@gmail.com'; // not allowed for this account // after $mailer->isSMTP(); $mailer->Username = 'noreply@example.com'; $mailer->From = 'noreply@example.com'; $mailer->Sender = 'noreply@example.com';
Defensive patterns
Strategy: validation
Validate before calling
if (!filter_var($mailer->From, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException("Invalid From address: {$mailer->From}");
}
$allowed = ['noreply@example.com', 'support@example.com'];
if (!in_array($mailer->From, $allowed, true)) {
throw new InvalidArgumentException('From not authorized for this SMTP account');
} Try / catch
try {
$mailer->send();
} catch (PHPMailer\PHPMailer\Exception $e) {
if (str_contains($mailer->ErrorInfo, 'from_failed')) {
error_log('MAIL FROM rejected: ' . $mailer->ErrorInfo); // includes server reply
}
} Prevention
- Send From as the authenticated account or a verified alias/sendas.
- Keep envelope Sender aligned with From to satisfy SPF/DMARC.
- Never hardcode arbitrary user-supplied From values.
- Read the embedded server reply in ErrorInfo when diagnosing.
When it happens
Trigger: Calling send() over SMTP when $this->smtp->mail($smtp_from) returns false: the server rejects the sender address (550/553/501 replies), the address is not authorized for the authenticated user (Gmail/Office365 SPF/alias rules), or the address is syntactically invalid.
Common situations: Gmail SMTP rejecting a From address that doesn't match the authenticated account or an approved alias/sendas, sending as a domain without SPF/DKIM alignment, empty or malformed From, or Exchange servers rejecting relay attempts from unknown senders.
Related errors
- $this->lang('data_not_accepted')
- $this->lang('recipients_failed') . $errstr
- Invalid address (From)
- $this->lang('instantiate')
- $this->lang('smtp_connect_failed')
AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13).
Data as JSON: /api/errors/32c70b4863facbd1.
Report an issue: GitHub.
Appendix: source
Thrown at libs/PHPMailer/PHPMailer.php:2034
*
* @return bool
*/
protected function smtpSend($header, $body)
{
$header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
$bad_rcpt = [];
if (!$this->smtpConnect($this->SMTPOptions)) {
throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
//Sender already validated in preSend()
if ('' === $this->Sender) {
$smtp_from = $this->From;
} else {
$smtp_from = $this->Sender;
}
if (!$this->smtp->mail($smtp_from)) {
$this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
throw new Exception($this->ErrorInfo, self::STOP_CRITICAL);
}
$callbacks = [];
//Attempt to send to all recipients
foreach ([$this->to, $this->cc, $this->bcc] as $togroup) {
foreach ($togroup as $to) {
if (!$this->smtp->recipient($to[0], $this->dsn)) {
$error = $this->smtp->getError();
$bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']];
$isSent = false;
} else {
$isSent = true;
}
$callbacks[] = ['issent' => $isSent, 'to' => $to[0], 'name' => $to[1]];
}
}
View on GitHub (pinned to 52820e87ca)