Sendmail succeeds, qmail fails


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Sendmail succeeds, qmail fails
# 1  
Old 05-07-2014
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.
Code:
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
Code:
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:
Code:
$ 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?
# 2  
Old 05-07-2014
This is what most folks do I think for attachments

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



# 3  
Old 05-07-2014
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.
# 4  
Old 05-30-2014
Problem solved with embarrassingly simple change

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:
Code:
Content-Transfer-Encoding: uuencode
begin 644 testfile.txt

Works:
Code:
Content-Transfer-Encoding: uuencode

begin 644 testfile.txt

So here is the fixed example that works in both qmail and sendmail:
Code:
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--


Last edited by charles_n_may; 05-30-2014 at 06:05 PM..
This User Gave Thanks to charles_n_may For This Post:
# 5  
Old 05-30-2014
Thank you for updating the thread.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail Fails to send emails from Linux server.

I m using free zoho mail client application (similar to microsoft outlook) on my mobile for all my emails to mohtashim@techx.com I wish to only recieve emails from my Linux Server details of which are: techx 3.10.0-514.10.2.el7.x86_64 #1 SMP CentOS release 7.3.1611 (Core). I try the below... (20 Replies)
Discussion started by: mohtashims
20 Replies

2. UNIX for Dummies Questions & Answers

read fails in Unix, but succeeds in Linux. Why?

Hi, When I use "read" to parse the sftp command sent via ptty, I ran into a very mysterious case below: --- In Unix, the command ‘quit' is lost. === Fri 13Apr12 15:42:47GMT-sftp_send_command: SENT Fri 13Apr12 15:42:47GMT-sftp_read_resp_line: Parse buffer=quit^M --> Command sent correctly... (2 Replies)
Discussion started by: HgHK
2 Replies

3. Red Hat

Qmail

hi all, i want to install Qmail but i don't from where can i get the package , and also if one know source that can explain qmail kindly tell me about it (3 Replies)
Discussion started by: linux_land
3 Replies

4. Shell Programming and Scripting

Expect: Block of lines should be executed only if access succeeds

Hello I'm using expect to create a script. I want some lines to be executed only if the telnet succeeds to the target host. Kindly check the code that i created. The problem i'm facing that while execting the script, the lines after login seems to be ignored. The password is not sent and also... (2 Replies)
Discussion started by: Hossam_Nox
2 Replies

5. Shell Programming and Scripting

execute ftp script until it succeeds

I have a ftp script that occasionally fails (connection lost error). I would like to execute the ftp command until it succeeds. Would the script below work? while do ftp -i -n <<EOF >> $LOG open $FTP_HOST user $FTP_LOGIN $FTP_PASSWD put filename.csv bye quit ... (5 Replies)
Discussion started by: soliberus
5 Replies

6. Red Hat

Sendmail fails receiving mail since the IP changed on Redhat Server

Hi, Since i move my Linux Redhat server on another Network with new IP address. WE'RE ABLE TO SEND MAIL OUTSIDE BUT we can not receive any incoming mail. It alway points to the old IP. I updated new IP in /etc/hosts and /etc/sysconfig/network then reboot the system. 10.117.32.20 is an old ip... (3 Replies)
Discussion started by: lamoul
3 Replies

7. Solaris

Qmail - possible?

Hi guys, Could you please advice me as im a new guy into Solaris ...is it possible to have qmail up and running on Solaris 10 and do you know where i can find some documentation on downloading and configuring - qmail? thank you guys vladi, (2 Replies)
Discussion started by: saveka
2 Replies

8. Programming

while vc++6 succeeds, g++ fails. ???

My code is at: http://rafb.net/p/E82U3C73.html It is a concept sample. I desperately tried to compile it with g++. To my surprise (in vmplayer/ win2k) vc++6 succeeds to compile it. I'm in very doubt. I used RedHat WS 4 , g++-3.4 and Debian Etch, g++-4.1 Comment this please!! mihai (4 Replies)
Discussion started by: mihk
4 Replies

9. UNIX for Dummies Questions & Answers

QMail Help

My company is running qmail on our Unix server. I would like to run a MySQL script whenever an email was sent to a specific email address. I don't want to have to check every email that comes in, so I was thinking that the script would run when the message arrives at the specific mailbox. Is there... (0 Replies)
Discussion started by: perryl7
0 Replies

10. News, Links, Events and Announcements

Linux mail servers benchmarks (Qmail, Sendmail,Postfix)

New Linux mail servers benchmarks website. Check out http://benchmarks.dmz.ro . (0 Replies)
Discussion started by: cipango
0 Replies
Login or Register to Ask a Question