Sendmail succeeds, qmail fails

I am attempting to send multipart formatted email using sendmail -t with attachments. The attachments always arrive as empty if sent from linux. They are intact if sent from AIX.

Does qmail not support attachments for multipart formatted email?

I have a legacy application which runs splendidly in AIX, generating formatted HTML email and adding mutliple attachments (.csv and .zip files).

This application is being migrated to linux and the sendmail implementation on the linux host is mini-qmail.

Here is a sample file which I can pipe to sendmail -t on either host to demonstrate the problem (If you try to run it, obviously doctor up the To: line so it sends to you).

Please, please don't try an experiment where you just pipe a file through uuencode to sendmail -t and tell me it works. That's not enough. The email has to be multipart, with formatted headers and sections.

From: Sample sendmail script <samplescript@mydomain.com>
To: myaddress@mydomain.com
Reply-to: DO NOT REPLY <noreply@mydomain.com>
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: all
Subject: Test email with attachment from myhost
Mime-version: 1.0
Content-Type: Multipart/Mixed; boundary="xxxxxq0w9e8r7xxxxx"
--xxxxxq0w9e8r7xxxxx
Content-Type: text/html
<HTML><BODY>
<H1>Here is your formatted data:</H1>
<TABLE border=1>
<tr><th>Column 1</th><th>Column 2</th></tr>
<tr><td>Data 1</td><td>Data 2</td></tr>
</TABLE>
</BODY></HTML>
--xxxxxq0w9e8r7xxxxx
Content-Type: text/plain
Content-Disposition: attachment; filename="testfile.txt"
Content-Transfer-Encoding: uuencode
begin 644 testfile.txt
M=&AI<R!I<R!T:&4@8V]N=&5N="!O9B!T:&4@871T86-H;65N=`IT:&ES(&ES
K('1H92!S96-O;F0@;&EN92!O9B!T:&4@871T86-H;65N="!C;VYT96YT"@``
`
end
--xxxxxq0w9e8r7xxxxx--

Now with the contents above saved in a file named pipe_to_sendmail, execute

cat pipe_to_sendmail | sendmail -t

The file arrives with an intact attachment that contains two lines of text if sent from AIX.

If sent from linux, the email looks the same, except the attachment arrives as an empty file.

In linux (2.6.32-220.el6.x86_64) the sendmail in my path is a symbolic link to mini-qmail:

$ which sendmail
/usr/sbin/sendmail
$ ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 28 Jan 16 08:29 /usr/sbin/sendmail -> /var/mini-qmail/bin/sendmail

---------- Post updated at 03:44 PM ---------- Previous update was at 01:08 PM ----------

So my admin installed "real" sendmail to replace qmail and the attachment now arrives intact. Although this works, I don't understand why qmail didn't succeed.

Does this mean qmail itself does not fully support attachments in multipart email? Or is there a difference in the way it is configured that causes its attachments in multipart emails to arrive empty?

This is what most folks do I think for attachments

uuencode file.tar.gz file.tar.gz | mailx -s "My files" joe-user@host.com

[/COLOR]

Unfortunately that's not sufficient because it doesn't have a formatted HTML body, isn't multipart, and doesn't have the custom headers required. You really have to use my example.

The code that generates the custom sendmail headers, HTML formatted body, and attachments is embedded in the database. Using a different program isn't really an option. It's also not a matter of just sending an email with attachments. It has to be the whole thing.

After much anxiety this problem is solved.

Evidently qmail requires a blank line between the Content-type declarations for the attachment and the beginning of the encoded content. Sendmail is not as picky and does not require this blank line.

In my example from this thread, putting a blank line between these two lines makes the attachment succeed with both qmail or sendmail:

Fails:

Content-Transfer-Encoding: uuencode
begin 644 testfile.txt

Works:

Content-Transfer-Encoding: uuencode

begin 644 testfile.txt

So here is the fixed example that works in both qmail and sendmail:

From: Sample sendmail script <samplescript@mydomain.com>
To: myaddress@mydomain.com
Reply-to: DO NOT REPLY <noreply@mydomain.com>
Auto-Submitted: auto-generated
X-Auto-Response-Suppress: all
Subject: Test email with attachment from myhost
Mime-version: 1.0
Content-Type: Multipart/Mixed; boundary="xxxxxq0w9e8r7xxxxx"
--xxxxxq0w9e8r7xxxxx
Content-Type: text/html

<HTML><BODY>
<H1>Here is your formatted data:</H1>
<TABLE border=1>
<tr><th>Column 1</th><th>Column 2</th></tr>
<tr><td>Data 1</td><td>Data 2</td></tr>
</TABLE>
</BODY></HTML>
--xxxxxq0w9e8r7xxxxx
Content-Type: text/plain
Content-Disposition: attachment; filename="testfile.txt"
Content-Transfer-Encoding: uuencode

begin 644 testfile.txt
M=&AI<R!I<R!T:&4@8V]N=&5N="!O9B!T:&4@871T86-H;65N=`IT:&ES(&ES
K('1H92!S96-O;F0@;&EN92!O9B!T:&4@871T86-H;65N="!C;VYT96YT"@``
`
end
--xxxxxq0w9e8r7xxxxx--
1 Like

Thank you for updating the thread.