Email Subject Length Issue

Home » CentOS » Email Subject Length Issue
CentOS 16 Comments

Hello all

I seem to be running into a subject length issue on email. Is there any way to increase that ?

Thanks,

jerry

16 thoughts on - Email Subject Length Issue

  • Am 12.04.2017 um 21:27 schrieb Jerry Geis:

    There needs to be more context. Where and how do you face the limit?
    Client-side or on the mail transport? The RFC defines a limit for mail headers and the subject is one of them. Would be very strange to hit that though.

    Alexander

  • Sure… Its local. I run this command:
    echo “” | mail -s “Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4 %.Informational Text:
    OB SURGERY HUMIDITY ALARM” email_test

    where email_test is my local machine account.

    The subject gets truncated:

    Jerry

  • you’ll need to be a whole lot more specific. I’ve seen emails with stupidly long subjects, one message sent to a list recently had the entire message body pasted onto the subject.

    Where are you running into this issue, how is it manifesting itself, what software is involved (email client, email server, email list server?)

    I see you’re using gmail, are you sure this problem isn’t specific to gmail?

  • Sorry for the extra email. It send to quickly.

    procmail: Assigning “SUBJECT= Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is”

    jerry

  • sounds like your issue is procmail then… I just used your exact command to send myself a message form a bone stock C6 system (sendmail as the email server) and recieved…

    (domain munged because I don’t want to recieve ANY email at this host)

    From – Wed Apr 12 12:40:34 2017
    X-Account-Key: account1
    X-UIDL: 58ee82b100000004
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-Keys:
    Return-Path: Received: from new.XXX.com (new.XXX.com [207.111.XXX.YY])
    by hogranch.com (8.11.6/8.11.6) with ESMTP id v3CJeKi25266
    for ; Wed, 12 Apr 2017 12:40:20 -0700
    Received: by new.freescruz.com (Postfix, from userid 500)
    id 98C33606BE; Wed, 12 Apr 2017 12:40:20 -0700 (PDT)
    Date: Wed, 12 Apr 2017 12:40:20 -0700
    To: pierce@hogranch.com Subject: Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is
    in Alarm at PRI3 with a value of 63.4 %.Informational Text:OB SURGERY
    HUMIDITY ALARM
    User-Agent: Heirloom mailx 12.4 7/29/08
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20170412194020.98C33606BE@new.XXX.com>
    From: pierce@XXX.com (John R Pierce)

  • So I am using sendmail on C7.

    I added to the .procmailrc file VERBOSE and a log file.

    procmail: Assigning “SUBJECT= Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is”

    This command:
    echo “” | mail -s “Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4 %.Informational Text:
    OB SURGERY HUMIDITY ALARM” email_test

    With email_test being a local account… clearly my subject is truncated. Is there a way to expand that?

    Thanks,

    Jerry

  • A “Subject:” line is just a structured text line in the message body and MTAs (e.g., sendmail) don’t do anything differently with it than any other line in a message body. The max length is 998 “characters”.

    I suspect that your MUA or more likely procmail is where the truncation is taking place. I just did:

    /bin/mailx -s”… 200+ character subject …”

    on a C6/sendmail machine and it worked fine.

  • still on C6… (don’t have a c7 server configured with an email service).

    [pierce@new ~]$ mail Heirloom Mail version 12.4 7/29/08. Type ? for help.
    “/var/spool/mail/pierce”: 1 message 1 new
    >N 1 John R Pierce Wed Apr 12 13:00 20/738 “Tornado Monday,
    03/27/2017 at 20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4 %.I”
    & 1
    Message 1:
    From pierce@XXX.com Wed Apr 12 13:00:09 2017
    Return-Path: X-Original-To: pierce Delivered-To: pierce@XXX.com Date: Wed, 12 Apr 2017 13:00:09 -0700
    To: pierce@new.freescruz.com Subject: Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is
    in Alarm at PRI3 with a value of 63.4 %.Informational Text:OB SURGERY
    HUMIDITY ALARM
    User-Agent: Heirloom mailx 12.4 7/29/08
    Content-Type: text/plain; charset=us-ascii From: pierce@XXX.com (John R Pierce)
    Status: R

    &

  • ok, wait, I do have a c7 test VM…

    [piercej@c7test ~]$ echo “” |mail -s “Tornado Monday, 03/27/2017 at
    20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4
    %.Informational Text:OB SURGERY HUMIDITY ALARM” piercej
    [piercej@c7test ~]$ mail Heirloom Mail version 12.5 7/5/10. Type ? for help.
    “/var/spool/mail/piercej”: 1 message 1 new
    >N 1 John R Pierce Wed Apr 12 13:06 20/888 “Tornado Monday,
    03/27/2017 at 20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4 %.I”
    & 1
    Message 1:
    From piercej@c7test.XXX.com Wed Apr 12 13:06:22 2017
    Return-Path: X-Original-To: piercej Delivered-To: piercej@c7test.XXX.com Date: Wed, 12 Apr 2017 13:06:22 -0700
    To: piercej@c7test.XXX.com Subject: Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is
    in Alarm at PRI3 with a value of 63.4 %.Informational Text:OB SURGERY
    HUMIDITY ALARM
    User-Agent: Heirloom mailx 12.5 7/5/10
    Content-Type: text/plain; charset=us-ascii From: piercej@c7test.XXX.com (John R Pierce)
    Status: R

    &

    so, your issue is something specific on your configuration. hmm, c7’s default email service is postfix, not sendmail, for what /thats/ worth.

  • Oh I understand now what is happening. The subject is coming in as three lines.

    Subject: Tornado Monday, 03/27/2017 at 20:27:02. The Point BB.OBSURGRH is in Alarm at PRI3 with a value of 63.4 %.Informational Text: OB SURGERY
    HUMIDITY ALARM

    I’m not getting the second two lines.

    How “should” one correctly get the subject ???

    What I did was in my .procmailrc file SUBJECT=`cat | grep Subject:`

    So this resulted in only the first line and not grabbing the additional 2
    lines.

    Is there a way to correctly get the subject that I have not found?

    Thanks for the tips. It led me to the above.

    Jerry

  • There’s supposed to be a “null” line between the structured (header)
    text lines and the rest of the body. The “Subject:” is generally the last of the structured text lines, so you should be able to start your read with the “Subject:” tag and continue reading until you hit the “null” line.

  • are you saying the subject is 3 lines (not one long line that wraps over 3) before you try to send it as email?

    if so you need to strip out the newlines (or CR/LF) or whatever is there as linebreaks.

    Have a look at the “tr” command, possibly the -d option.

    echo “now
    is
    the
    time” | tr -d “\12\15”

    prints “now is the time” but note that there is no newline at the end of the string, so you’d need to add one back.

    if you do this, you get the trailing newline, though this looks pretty weird:

    /usr/bin/echo -e `echo “now is the time” | tr -d “\12\15″`

    good luck!

  • Am 12.04.2017 um 22:03 schrieb Richard:

    [ … ]

    No, the subject of a mail message is a defined field and part of the message header, not the body of the message. Just see RFC 5322. Message header and (optional) body are separated by an empty line. While there are specific rules for message header fields there are (nearly) none for the character flow of the mail body (MIME RFCs aside). The 998 character limit per line applies for both the header and the body.

    That turned out to be the case as the OP didn’t cover folding of long header fields (RFC 5322 2.2.3).

    Alexander

  • Am 12.04.2017 um 22:24 schrieb Richard:

    [ … ]

    No, there is simply no rule nor evidence that the subject header line is or should be the last of all header lines. Typically you see it somewhere within the mail’s header.

    Alexander

  • You’ll need to grab the line that starts with “Subject:” and then continue grabbing lines until you find one that doesn’t start with whitespace. I don’t think you can do this with grep, but you should be able to do it with perl, sed, or awk.