LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Pipe email to extract attachments. Script works, but email sender receives an error! (http://www.linuxquestions.org/questions/linux-server-73/pipe-email-to-extract-attachments-script-works-but-email-sender-receives-an-error-805057/)

ceashton 04-29-2010 05:54 PM

Pipe email to extract attachments. Script works, but email sender receives an error!
 
Dear all,

I'm trying to automatically extract email attachments by piping new email to a perl script. Whilst the script performs as expected, stripping the attachment and delivering them to a directory, the email sender receives an email saying their email wasn't delivered.

The script (755 permissions) I am using to extract the attachments is one I found on the web and may be seen here:

http://tek-tips.com/faqs.cfm?fid=4138

This email account is intended to serve one particular purpose, so I have created a specific email account whereby all messages should be processed. The only filter currectly on this email account is the one that calls the processing script. The filter reads:

Code:

/home/accountname/binChris/unmime.pl
As I mentioned earlier, the script successfully processes the email, delivering MIME attachments to a directory defined in the script, but the email sender receives the following email:

Code:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

 pipe to |/home/accountname/binChris/unmime.pl
  generated by MY@RECEIVINGDOMAIN.COM

The following text was generated during the delivery attempt:

------ pipe to |/home/accountname/binChris/unmime.pl
      generated by *MY@RECEIVINGDOMAIN.COM ------

Received: from mail-BLAHBLAH.google.com ([209.85.218.179]:59735)
        by MYWEBSERVER.COM with esmtp (Exim 4.69)
        (envelope-from <MY@EMAILADDRESS.COM>)
        id 1O7cH6-00075b-94
        for MY@RECEIVINGDOMAIN.COM; Thu, 29 Apr 2010 23:32:04 +0100
Received: by bwz27 with SMTP id 27so917348bwz.12
      for <MY@RECEIVINGDOMAIN.COM>; Thu, 29 Apr 2010 15:32:11 -0700 (PDT)
Received: by 10.204.152.17 with SMTP id e17mr6564204bkw.105.1272580330599;
      Thu, 29 Apr 2010 15:32:10 -0700 (PDT)
Received: from MY.LOCAL.COMPUTER (SOMEALPHANUM.bagu.cable.ntl.com [???.???.???.???])
      by mx.google.com with ESMTPS id 14sm482144bwz.2.2010.04.29.15.32.09
      (version=TLSv1/SSLv3 cipher=RC4-MD5);
      Thu, 29 Apr 2010 15:32:09 -0700 (PDT)
Subject:
From: Chris <MY@EMAILADDRESS.COM>
Content-Type: multipart/alternative; boundary=Apple-Mail-21-67868337
Message-Id: <EDC000E7-65B8-4EF6-A55E-2DE74CFB9B28@times-studios.co.uk>
Date: Thu, 29 Apr 2010 23:32:07 +0100
To: MY@RECEIVINGDOMAIN.COM
Mime-Version: 1.0 (Apple Message framework v1078)
X-Mailer: Apple Mail (2.1078)

Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
        charset=us-ascii
test

... REST OF FILE I"VE CUT

Any pointers would be very much appreciated.

Many thanks,

Chris

PS I am in a shared hosting environment with
Kernel version 2.6.18-128.2.1.el5
cPanel Version 11.25.0-RELEASE
perl v5.8.8
exim (exim-4.69-23.1_cpanel_maildir)
Code:

$ cat /proc/version
Linux version 2.6.18-128.2.1.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) #1 SMP Tue Jul 14 06:39:56 EDT 2009


unSpawn 04-29-2010 07:02 PM

Quote:

Originally Posted by ceashton (Post 3952397)
Code:

pipe to |/home/accountname/binChris/unmime.pl

- What does the mail log on the server say about using that alias and pipe command?
- how is the filter called in /etc/aliases?
- should the user exim runs as be allowed to execute scripts in /home/${LOGNAME}/?

ceashton 04-30-2010 10:14 AM

Many thanks for the reply.

Code:

- What does the mail log on the server say about using that alias and pipe command
I'm on a shared hosting account, and so the mail logs aren't readable by myself.

Code:

- how is the filter called in /etc/aliases?
Again, I am on a shared hosting account with cPanel so I have just used the 'user level filtering' > 'add filter' in cPanel, as opposed to editing /etc/aliases directly. There is a text field entitled 'pipe to program', so I assumed there was no need for the pipe. This seemed to be validated by the script actually processing the email even though it returned a 'not delivered' message to the sender. I've tried adding in the pipe and the situation remains the same.

I've also tried creating a .forward file in /home/${LOGNAME}/, but it seems to be being ignored, or else I have an error in it - guess I need the logs!

Code:

- should the user exim runs as be allowed to execute scripts in /home/${LOGNAME}/?
I don't know if the user exim runs as should be allowed to execute scripts in /home/${LOGNAME}/, but it certainly seems as though it can, as it runs the script to produce the extracted attachments. Is that a safe assumption? Whilst I'm debugging this, I have given the script and the directory it writes to 777 permissions just-in-case.

I noticed the perl script I am using (as referenced in my initial post) is from 2003, and I wondered if the age of the script may be the reason for the 'not delivered' message. Hence earlier this morning I started experimenting with uudeview.

In the intervening time however, the hosting provider appears to be having some trouble (none of my sites they host are available), so I am unable to perform any more testing. When the hosting company have resolved their issues I'll let you know haw I get on.

Once again, many thanks for replying,

Chris

unSpawn 05-01-2010 06:04 AM

Quote:

Originally Posted by ceashton (Post 3953067)
I'm on a shared hosting account, and so the mail logs aren't readable by myself.

Bummer.


Quote:

Originally Posted by ceashton (Post 3953067)
I don't know if the user exim runs as should be allowed to execute scripts in /home/${LOGNAME}/, but it certainly seems as though it can, as it runs the script to produce the extracted attachments. Is that a safe assumption?

Yes, quite.


Quote:

Originally Posted by ceashton (Post 3953067)
Whilst I'm debugging this, I have given the script and the directory it writes to 777 permissions just-in-case.

Best remove that now then. Just in case.


Quote:

Originally Posted by ceashton (Post 3953067)
I noticed the perl script I am using (as referenced in my initial post) is from 2003, and I wondered if the age of the script may be the reason for the 'not delivered' message.

If it interacts with the Mail Delivery Agent (MDA) part of Exim in a way the MDA does not get then maybe, yes.


All times are GMT -5. The time now is 06:31 AM.