cPanel

How to Fix “message has lines too long for transport” on cPanel

Emails bounce with “message has lines too long for transport”? Raise Exim's line length limit in WHM, and add it to smarthost transports such as MailChannels.

Emails sent from a cPanel server bounce straight back, whoever they are sent to, with an error like this:

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
  message has lines too long for transport

The server's mail log (/var/log/exim_mainlog) shows the same reason:

** user@example.com R=dkim_lookuphost T=dkim_remote_smtp: message has lines too long for transport

This guide explains the cause and how to fix it in WHM.

Quick answer

  1. In WHM, go to Service Configuration › Exim Configuration Manager › Mail.
  2. Raise Maximum line length for SMTP transports and click Save.
  3. If the server sends mail through a smarthost (for example MailChannels), also add message_linelength_limit to the smarthost's transport in the Advanced Editor, because the WHM setting does not apply there.

What you need: root access to WHM.

Why it happens

The email standard (RFC 5322) says a single line in an email may be at most 998 characters. Some email programs, website contact forms and newsletter tools ignore this and produce lines that are much longer, often in HTML emails. cPanel article

Exim, the mail server on cPanel servers, started enforcing this limit strictly in version 4.95 (early 2022), so messages that used to go out suddenly began to bounce. cPanel then added a setting to raise the limit.

Fix 1: Raise the limit in WHM

  1. Log in to WHM as root.
  2. Go to Home › Service Configuration › Exim Configuration Manager.
  3. Open the Mail tab.
  4. Find Maximum line length for SMTP transports and enter a higher value, for example 1000000.
  5. Click Save at the bottom of the page. Exim restarts with the new setting.

cPanel article

To confirm the setting was saved:

grep -i linelength /etc/exim.conf.localopts
message_linelength_limit=1000000

Send the failed message again to test.

Note: this lets your server send these messages. The receiving server may still apply the 998-character rule and reject them. If one particular program or form causes the problem, the lasting fix is to update it or change its settings so it sends properly formatted email.

Fix 2: Smarthosts and custom routers (such as MailChannels)

If the error continues after Fix 1, check whether your server sends mail through a smarthost: an outside mail relay service such as MailChannels (how to set up MailChannels on cPanel), set up as a custom Exim transport.

The WHM setting from Fix 1 only applies to cPanel's own mail routes. A smarthost has its own transport, which ignores it. cPanel article on custom routers

To fix it:

  1. Go to WHM › Service Configuration › Exim Configuration Manager › Advanced Editor.
  2. Find your smarthost's transport, in the box after @TRANSPORTSTART@.
  3. Add a message_linelength_limit line to it. For a MailChannels transport, for example:
mailchannels_smtp:
  driver = smtp
  hosts_require_auth = *
  tls_tempfail_tryclear = true
  message_linelength_limit = 1000000
  1. Most smarthost setups have more than one transport (for example, one for DKIM-signed mail and one without). Add the line to each of them.
  2. Click Save. Exim restarts automatically; if mail still fails, restart it in WHM › Restart Services › Mail Server (Exim).

Your own transport may have different settings from the example. Only add the message_linelength_limit line; leave the rest as it is.

Sources

  1. cPanel: Exim fails to send email: message has lines too long for transport
  2. cPanel: "Message has lines too long for transport" with custom routers

Written by Tharanga. Commands and procedures depend on your system and software version.

How we approach technical guides →
FOLLOW THE THREAD

Keep exploring

All guides
Linux1 min read

How to Check Disk Space in Linux

See how much disk space is free on a Linux server and find the folders using the most space, with two beginner-friendly commands: df and du.