2

I am having problems sending an email from one email address to another on my domain. I am using a shared server. I use weather software which automatically constructs and sends the email message. I have omitted the host, domain and IP info and replaced them like so: host= example.co.uk, domain = mydomain.co.uk .

The situation is I run a mail group using email address (weatherinfo@) and some users in the group set auto-responders. Therefore to prevent these from going to the whole group the email is sent from a different address (reports@) to weatherinfo@ with the reports@ address receiving the auto-responder messages.

I am getting the following message from the mail delivery system when trying to send the email to weatherinfo@ from report@:

This is the mail system at host mailauth.example.co.uk.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

               The mail system

<[email protected]>: host 127.0.0.1[127.0.0.1] said: 554 5.6.0
Reject, id=02474-18 - BAD HEADER (in reply to end of DATA command).

The error log accompanying the email shows:

Reporting-MTA: dns; mailauth.example.co.uk
X-Postfix-Queue-ID: 88002C306D
X-Postfix-Sender: rfc822; [email protected]
Arrival-Date: Fri,  2 May 2014 22:00:43 +0100 (BST)

Final-Recipient: rfc822; [email protected]
Original-Recipient: rfc822;[email protected]
Action: failed
Status: 5.6.0
Remote-MTA: dns; 127.0.0.1
Diagnostic-Code: smtp; 554 5.6.0 Reject, id=02474-18 - BAD HEADER

The header from the original message is:

Return-Path: <[email protected]>
Received: from LAPTOP (helium.example.co.uk [IP Address])
by mailauth.example.co.uk (Postfix) with ESMTPA id 88002C306D
for <[email protected]>; Fri,  2 May 2014 22:00:43 +0100 (BST)
To: [email protected]
From: [email protected]
Subject: WEATHER REPORT
Reply-To: [email protected]
Date: Fri, 02 May 2014 23:00:56 +0100
Message-Id: <[email protected]>
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"

Why is this message being rejected? Is this being caused by my software or the server? If it is the software what does the developer need do to fix it? If it is the server what should I ask my host to do to overcome this problem?

2
  • Problem resides with whatever system you are using to send the email, which is doing something weird with headers, apparently.
    – Peter
    May 3, 2014 at 2:09
  • 3
    Doe the message really have two message-id headers?
    – zhenech
    May 3, 2014 at 5:09

2 Answers 2

3

It appears you may be triggering a spam filtering rule. Your address is listed in the Spamhaus PBL list which indicates your IP address should not be originating email to the Internet. Spamhaus provides clear documentation on their policies.

If you want reliable delivery to the Internet the server sending to the Internet needs a fixed IP address with DNS configured to pass rDNS validation. Your mail server should identify itself with the domain you have configured for rDNS.

If you don't have a fixed IP address with appropriate DNS entries use your provider's email relay server to deliver the email.

As other have noted you seem to have an extra Message-Id header being added. This may be causing header validation to fail. (SPAM is much more likely to have bad headers than valid email.)

4
  • I have checked my servers domain and IP address and they don't appear to be blacklisted. However when using spamhaus PBL to check my laptops IP address it gives the message 'It is the policy of BT Retail that unauthenticated email sent from this IP address should be sent out only via the designated outbound mail server allocated to BT Retail customers.' Is it possible that the spam filter on my server is detecting this and therefore because my IP is listed on PBL it is rejecting the email? May 4, 2014 at 14:56
  • @RossHodgman You should always use a relay for you laptop. Your IP is likely listed in the PBL because it is dynamic and therefore cannot be reliably reached to send status messages or send replies. Well over 90% of the spam I receive comes from servers which don't have the a static IP address and the requisite rDNS entries. Please do NOT try to emulate them. Use your providers relay.
    – BillThor
    May 4, 2014 at 21:36
  • Thank you for your answers. I have now found the answer to the problem. It is a case of spamhaus have blacklisted all of BTs dynamic IP addresses. According to BT it is to prevent their servers being used to send spam. The way around it is to connect it to the BT mail account. This lets BT know that emails with [email protected] in the header are legitimate and therefore cleared to be relayed to my server. May 4, 2014 at 23:24
  • Ross, as I see it, that makes this answer substantially correct. Local etiquette is that when you're happy with an answer you accept it by clicking on the tick outline next to it; that drives the SF reputation system for both you and the author of the answer. My apologies if you already knew this.
    – MadHatter
    May 5, 2014 at 4:54
2

I can see two problems with the headers you cited. First of all the Received header is incorrectly formatted. When a header spans multiple lines, all but the first line must be indented. Additionally there are two Message-ID headers.

It would be possible for a mail server to process a mail without ever parsing the already existing headers. So, there may be a way to turn off that validation. But rather than turning off validation, I recommend fixing the formatting of the headers, since they may cause you other problems in the future.

7
  • I have run further tests with the email being sent from gmail to a test email account on my domain and it works and the message is forwarded to my private yahoo email account which is in the test mail group. So it seems for some reason my server doesn't like the email when it is sent from [email protected] to [email protected]. Why is my server rejecting these email messages and is there any way of getting the server to allow emails from my domain through without being checked? May 3, 2014 at 17:50
  • I have noticed that the header of the email I received in my yahoo inbox shows the following: Received-SPF: softfail (transitioning domain of gmail.com does not designate 91.222.8.98 as permitted sender). Could this indicate an issue with the server settings which may be causing the bad header problem or is it unrelated? If it is the cause to the bad header problem how would I go about fixing it? May 3, 2014 at 17:54
  • You could take each of those two mails and resend them unmodified directly to localhost using either /usr/lib/sendmail or telnet ::1 25. If it will still accept one and reject the other, you can start doing a binary search on which header fields cause that difference.
    – kasperd
    May 3, 2014 at 17:54
  • 1
    No idea if an SPF softfail could cause a mailserver to reject a mail like that. SPF is inherently incompatible with forwarding. You can work around that by configuring the forwarding mail server to replace the envelope-sender, or by configuring the receiving mail server to be less restrictive in validation of SPF headers.
    – kasperd
    May 3, 2014 at 17:58
  • I have just tried using telnet to send two different versions of the original email but they have been rejected. I have tried using the original header in one message and just the contents of the message minus the header in another but both were rejected with error message: Reject, id=08545-12 - BAD HEADER (in reply to end of DATA command). I have tried using telnet to send a message typed into the cmd window, but it got rejected. All telnet comms were working with the server responding in the correct manner. Is this the mail server being overzealous with its spam filtering? May 3, 2014 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .