We wish to do the following: 1. receive an email with an attachment 2. process the email body to get some information from it 3. send an outbound email to an email address based on the information derived from step 2. The email will include the attachment received in step 1 I'm not sure where to start with this one so any suggestions would be appreciated.
On Mon, 21 Sep 2009 05:49:29 +1200 CSB wrote:> We wish to do the following: > 1. receive an email with an attachment > 2. process the email body to get some information from it > 3. send an outbound email to an email address based on the information > derived from step 2. The email will include the attachment received in step > 1You should be able to string a few commands together in a script to get what you want, part of which depends on how you pick up and send out your email. Do you have your own mailserver? If you don't have your own mailserver (or even if you do), this is one solution: Step 1: fetchmail or getmail. I personally prefer getmail but that's just me. Step 2: http://www.codealias.info/technotes/extracting_attachment_from_e-mail_using_uudecode Step 3: http://www.cleancode.org/projects/email If you have your own mailserver, you can do steps 1 and 3 in a more "direct" manner, if you wish. -- MELVILLE THEATRE ~ Melville Sask ~ http://www.melvilletheatre.com
Use a mailer. That gives you complete control over how you process incoming messages since it will be your own program. We can implement it for you if you like. Thanks, Neil -- Neil Aggarwal, (281)846-8957, www.JAMMConsulting.com Will your e-commerce site go offline if you have a DB server failure, fiber cut, flood, fire, or other disaster? If so, ask about our geographically redundant database system.> -----Original Message----- > From: centos-bounces at centos.org > [mailto:centos-bounces at centos.org] On Behalf Of CSB > Sent: Sunday, September 20, 2009 12:49 PM > To: centos at centos.org > Subject: [CentOS] Receive, process and send email > > We wish to do the following: > 1. receive an email with an attachment > 2. process the email body to get some information from it > 3. send an outbound email to an email address based on the information > derived from step 2. The email will include the attachment > received in step > 1 > > I'm not sure where to start with this one so any suggestions would be > appreciated. > > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos
On Mon, 21 Sep 2009, CSB wrote:> We wish to do the following: > 1. receive an email with an attachment > 2. process the email body to get some information from it > 3. send an outbound email to an email address based on the information > derived from step 2. The email will include the attachment received in step > 1 > > I'm not sure where to start with this one so any suggestions would be > appreciated. >procmail is a good place to start. There are multiple man pages and examples. Experiment with a throw away account til you get it figured out. It is easy to do strange and unexpected things... ---------------------------------------------------------------------- Jim Wildman, CISSP, RHCE jim at rossberry.com http://www.rossberry.com "Society in every state is a blessing, but Government, even in its best state, is a necessary evil; in its worst state, an intolerable one." Thomas Paine
CSB wrote:> We wish to do the following: > 1. receive an email with an attachment > 2. process the email body to get some information from it > 3. send an outbound email to an email address based on the information > derived from step 2. The email will include the attachment received in step > 1 > > I'm not sure where to start with this one so any suggestions would be > appreciated.Directing received email to a program can be done either with a sendmail alias that pipes to a program or a procmail recipe, depending on whether the address is a real system user or not. If you want to program in perl, look at MIME::tools to parse the inbound copy's body and attachments and perhaps Mail::Sender to reassemble and re-send. -- Les Mikesell lesmikesell at gmail.com
On Sunday 20 September 2009, "CSB" <kjcsb at xnet.co.nz> wrote:> We wish to do the following: > 1. receive an email with an attachment > 2. process the email body to get some information from it > 3. send an outbound email to an email address based on the information > derived from step 2. The email will include the attachment received in > step 1 > > I'm not sure where to start with this one so any suggestions would be > appreciated.If it's a minor amount of processing, you can just pipe it to a script from procmail or even straight from the MTA. I don't really like that mechanism though - too prone to produce bounces in the case of long processing times or errors. It's better to dump them in a Maildir and use it as a queue for a polling script. Perl in particular has a bunch of libraries available to correctly parse MIME messages and extract addresses and attachments and stuff. Don't write your own parser. -- "No animals were harmed in the recording of this episode. We tried but that damn monkey was just too fast."