SMTP Error: 500 5.2.3 Line Too Long Issue

Following is the Golang script to request smtp

`package main
import (
“crypto/tls”
“fmt”
“log”
“net/smtp”
“strings”
)
func main() {
smtpHost := “kumomta.domain.io”
smtpPort := “587”
username := “user@gmail.com”
password := “Kumomta@123”
toEmail := “to@gmail.com”
fromEmail := “info@kumomta.domain.com”
longLine := strings.Repeat(“A”, 2000) // Change 2000 to a higher value if needed
message := fmt.Sprintf(“Subject: Test Line Too Long Issue\r\n”+
“From: %s\r\n”+
“To: %s\r\n”+
“\r\n”+
“%s\r\n”,
fromEmail, toEmail, longLine)
conn, err := smtp.Dial(smtpHost + “:” + smtpPort)
if err != nil {
log.Fatal(“Connection Error:”, err)
}

tlsConfig := &tls.Config{
    InsecureSkipVerify: true, 
    ServerName:         smtpHost,
}

if err = conn.StartTLS(tlsConfig); err != nil {
    log.Fatal("STARTTLS Error:", err)
}
auth := smtp.PlainAuth("", username, password, smtpHost)
if err = conn.Auth(auth); err != nil {
    log.Fatal("Authentication Error:", err)
}
if err = conn.Mail(fromEmail); err != nil {
    log.Fatal("Mail FROM Error:", err)
}
if err = conn.Rcpt(toEmail); err != nil {
    log.Fatal("RCPT TO Error:", err)
}
wc, err := conn.Data()
if err != nil {
    log.Fatal("DATA Error:", err)
}
_, err = wc.Write([]byte(message))
if err != nil {
    log.Fatal("Message Writing Error:", err)
}
err = wc.Close()
if err != nil {
    log.Fatal("Close Error:", err)
}
conn.Quit()
fmt.Println("Email Sent Successfully!")

}`

Error response : 500 5.2.3 line too long

Log

{“type":“Rejection”,“id”:“”,“sender”:"info@kumomta.domain.io”,“recipient”:"user@gmail.com",“queue”:“”,“site”:“”,“size”:0,“response”:{“code”:500,“enhanced_code”:{“class”:5,“subject”:2,“detail”:3},“content”:“line too long”,“command”:“DATA”},“peer_address”:{“name”:“localhost”,“addr”:“10.10.18.38”},“timestamp”:1740546713,“created”:1740546713,“num_attempts”:0,“bounce_classification”:“Uncategorized”,“egress_pool”:null,“egress_source”:null,“source_address”:null,“feedback_report”:null,“meta”:{“received_from”:“10.10.18.38:57694”},“headers”:{},“delivery_protocol”:null,“reception_protocol”:null,“nodeid”:“517ab33b-5d14-41d0-8ed3-ad38d6ab3d60”,“session_id”:“4dc50692-4a1d-4b1a-9ec9-dcd8dc820a8c”}

This seems to be working exactly as designed. You are injecting a string of 2000 “A”s with no spaces and KumoMTA is replying with a line too long error. There is no where to break the line. This is working properly.

If you send a real world test, like a paragraph with no carriage returns then you will probably see the result you expect to see

Ok. But does the function ‘check_fix_conformance’ automatically fix this issue as per the documentation?

kumo.on('smtp_server_message_received', function(msg) print("enter smtp_server_message_received") local failed = msg:check_fix_conformance( 'MISSING_COLON_VALUE', 'LINE_TOO_LONG' ) if failed then kumo.reject(552, string.format('5.6.0 %s', failed)) end end)

In the above code, I added a print statement, but it is not working. The functionality does not enter the “smtp_server_message_received” function.

It is being rejected at the listener and never making it as far as your print statement.

have you increased the line limit? Since you again have not provided the requested information, I cannot tell.

The requested Golang code is already attached above. Or did you mean the journal log?

Not increased the line limit, because we can’t predict the client request limit

Huh

kumo.on(‘init’, function()

kumo.start_esmtp_listener {
    listen = '127.0.0.1:9999',
    client_timeout = '60 minutes',
    line_length_hard_limit = 50 * 1024 * 1024,
}

end)

Just increase the line length first

Ok. But my concern is , we can’t predict the line length of client request

Well, why do you need to predict it? Just set it to a large number

Impact of Setting line_length_hard_limit to a Large Number in MTA
Negative Effects:

❌ RFC Non-Compliance – Exceeding 998 characters violates RFC 5322, causing email rejections.
❌ Email Delivery Issues – Many SMTP servers will reject or truncate long lines (451 4.5.3 Too many characters in one line).
❌ Increased Spam Score – Long unbroken lines trigger spam filters (SpamAssassin, Gmail, Outlook).
❌ Rendering Problems – Email clients (Gmail, Outlook, Apple Mail) may break or truncate long lines.
❌ Queue Overload – Large messages slow down MTA performance, increasing processing time.
❌ Memory & CPU Overhead – Unwrapped large lines consume more resources in SMTP handling

Uhh, then I guess don’t accept malformed emails.. :stuck_out_tongue:

What’s the problem?