Home » Linux » Attachments missing with altermime and postfix

Attachments missing with altermime and postfix

We recently experienced a problem with attachments going missing when using altermime to add a disclaimer to emails. The problem was only evident when the client was Outlook or Entourage (mange tout Rodney, mange tout). It was a real head scratcher as some emails would go through fine, others would be oddly truncated.

I even resorted to ‘catting’ out the email to file before and after applying the disclaimer, and then running diff on the resulting pair of files, but there was apparently no difference bar of course the added disclaimer text.

After protracted googling by myself and a colleague, we found that the Microsoft clients, when parsing the emails prior to sending (which all clients do to chop the lines down to the RFC specified length) allow single full stops to appear by themselves on their own lines. Now Postfix handles these fine when the email comes in over SMTP. However, when it comes out of the disclaimer script, it is injected back into the mail queue with the sendmail command. Seems that this sees the full stop and accepts it as the end of the email, thereby neatly truncating it sans attachment and often without some of the text.

To get around this, we added a single line to the disclaimer script, just prior to the sendmail command:

sed -i 's/^\.$/. /g' in.$$

where in.$$ is the mail. This adds a single space after the full stop which gets around the problem. I hope this saves someone a few hours.

Edit: After spotting a comment on howtoforge, it seems there’s a flag you can set for sendmail to stop it seeing single dots as EOF:

-i Ignore dots alone on lines by themselves in incoming mes-
sages. This should be set if you are reading data from a
file.

which is a lot neater than the fix above. Just sendmail -i in.$$

2 thoughts on “Attachments missing with altermime and postfix

  1. Hi,

    thx for that tip, you didn’t just save me a few hours but the day I guess!

    Cheers,
    Florian

  2. Thanks Florian, glad to have helped, it took an awful lot of headscratching to figure it out!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>