You are hereFetchExc and Procmail

FetchExc and Procmail


By edwin - Posted on 09 June 2009

Click here for reference article.

I have a customer that gives me access to their email servers via Citrix and Outlook Web Access (OWA) (http://mail.domain.com/exchange). They expect me to check email all day so I found myself checking email 100 times a day via Citrix and it was becoming annoying. I have a blackberry and I wanted to use it to receive emails as they arrive. I found myself logging on to the Outlook Mobile Access website (http://mail.domain.com/oma) but that was very slow and buggy. I also tried forwarding all the email using a rule but that had the bad effect of forwarding EVERY email to my blackberry; I get about 200 emails from monitoring applications a day that get routed to folders using Outlook rules. Also, forwarding emails outside of the organization is against company policy and any Exchange administrator could see my forwarding rule.

I finally found my answer reading Paul Nicholls' blog where he bypassed his schools anti-forwarding policy.

I already knew about fetchExc but was lost with the documentation.

Based on his article and my trial and error, my fetchExc.properties looks as follows:

ExchangeServer=mail.domain.com
ExchangePath=exchange
MailServer=localhost
DestinationAddress=/usr/bin/procmail
Username=user1
Password=password1
Domain=DOMAIN
Delete=false
All=false
Secure=true
ProcMail=true
FBApath=/exchweb/bin/auth/owaauth.dll
NoEightBitMime=false

My ~/.procmailrc file looks as follows:

:0
! user1@vzw.blackberry.net

I tested my work by executing:

/usr/bin/java -jar fetchExc.jar $* >> fetchExc.log 2>> fetchExc.err

In fetchExc.log I found an entry similar to this:

Starting fetchExc v2.0 Fri, 19 Jun 2009 07:38:01
1 message for user1 at mail.domain.com
Message 1 sent OK

I had a lot of issues with PATH and trying to get the script suggested by Paul to work in cron, so I decided to use the following:

  1. */1 * * * * /usr/bin/java -jar /home/user1/fetchExc-2.0/fetchExc.jar -p /home/user1/fetchExc-2.0/fetchExc.properties >> /home/user1/fetchExc-2.0/fetchExc.log 2>> /home/user1/fetchExc-2.0/fetchExc.err

Every minute of the day, my server checks for new messages. Only messages that stay in the Inbox are forwarded.

The logs started getting big fast, so I had to direct logrotate to clean them for me. I created the file /etc/logrotate.d/fetchExc with the following information:

/home/user1/fetchExc-2.0/fetchExc.err {
rotate 3
daily
compress
missingok
notifempty
}

/home/user1/fetchExc-2.0/fetchExc.log {
rotate 3
daily
compress
missingok
notifempty
}

Now I can check on whether fetchExc was doing its thing for the last 3 days. Happy hacking.

That's one reason why I don't want to set up my phone to have my emails forwarded to it. I get so many random stupid emails that i'd rather not be getting bugged every two minutes about the dumb new thing some guy said that my dad heard about or the newest feng shui cure from a website. I really need to just set up a new email account to use for my smart phone that is only known to a select few people.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <img> <span>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Images can be added to this post.

More information about formatting options