ellite/Wallos · critical · Exception

$this->lang('data_not_accepted')

Error message

$this->lang('data_not_accepted')

What it means

Thrown in smtpSend() when at least one recipient was accepted but the server rejects the message content during the DATA phase: $this->smtp->data($header . $body) returns false. The localized 'data_not_accepted' message is thrown as a critical exception. This means the session and recipients were fine but the server refused the actual message.

Solutions

  1. Enable SMTPDebug = DEBUG_SERVER and read the SMTP reply after DATA (e.g. 552 = too large, 554 = rejected content).
  2. Reduce message size: shrink or remove attachments (check server size limit, often 10-25MB).
  3. Inspect custom headers for invalid values/newlines; use $mailer->addCustomHeader() with clean values.
  4. Add standard headers (Message-ID via $mailer->MessageID, Date, Return-Path) that spam filters require.
  5. Retest content: send a plain minimal message to isolate whether the body/attachments trigger the rejection.

Example fix

// before
$mailer->addAttachment('/path/50MB-video.mp4'); // exceeds server limit
$mailer->send(); // SMTP error: DATA not accepted
// after
$mailer->addAttachment('/path/report.pdf'); // small, allowed type
$mailer->MessageID = '<' . bin2hex(random_bytes(16)) . '@example.com>';
$mailer->send();
Defensive patterns

Strategy: try-catch

Validate before calling

$size = filesize($attachmentPath);
if ($size > 10 * 1024 * 1024) { // 10MB server-typical limit
    throw new InvalidArgumentException("Attachment {$attachmentPath} exceeds server DATA limit");
}

Try / catch

try {
    $mailer->send();
} catch (PHPMailer\PHPMailer\Exception $e) {
    if (str_contains($mailer->ErrorInfo, 'data_not_accepted') || str_contains($mailer->ErrorInfo, 'DATA')) {
        error_log('SMTP DATA rejected: ' . $mailer->ErrorInfo); // 552=too large, 554=content
        // shrink message or strip attachments and retry
    }
}

Prevention

When it happens

Trigger: Calling send() over SMTP when smtp->data() fails: server rejects message content (554), message too large, malformed headers from bad encodings/custom headers, anti-spam filters rejecting content, or connection dropped mid-DATA.

Common situations: Oversized attachments exceeding the server's message-size limit, spam filters (Rspamd/SpamAssassin) rejecting content or missing headers, invalid injected headers causing protocol desync, greylisting/content policies on corporate relays.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13). Data as JSON: /api/errors/fae31806dc993b5b. Report an issue: GitHub.

Appendix: source

Thrown at libs/PHPMailer/PHPMailer.php:2055

        $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]];
            }
        }

        //Only send the DATA command if we have viable recipients
        if ((count($this->all_recipients) > count($bad_rcpt)) && !$this->smtp->data($header . $body)) {
            throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL);
        }

        $smtp_transaction_id = $this->smtp->getLastTransactionID();

        if ($this->SMTPKeepAlive) {
            $this->smtp->reset();
        } else {
            $this->smtp->quit();
            $this->smtp->close();
        }

        foreach ($callbacks as $cb) {
            $this->doCallback(
                $cb['issent'],
                [[$cb['to'], $cb['name']]],
                [],
                [],
                $this->Subject,

View on GitHub (pinned to 52820e87ca)