For more use of E-Mail with PSYC, see SMTP, Mailcast and other Software Projects.

This is how Mozilla Thunderbird likes to check for new e-mail:

thunderbird-10-minutes.png

Polling for new mail every ten minutes? What a bad idea! Consumes more traffic, requires the e-mail client to stay in memory and most of all, it makes you slow at replying to other people's e-mails! Don't you want to be one of those lightning answerers, too? Stop hitting that Get Mail button. Let PSYC tell you in real-time when new e-mail is arriving!

Contents

Enter psycmail

You need to have a unix login on your mailer, then you can install utility/psycmail.c from the psyced distribution. It's written in C and parses emails in RFC822 format and creates "new mail" notifications to be displayed in realtime. You'll find instructions in the file.

Get yourself realtime notification of Email Reception

When you download and install psyced, there's a directory named "utility". Within this directory are a few programs that work with PSYC to do useful things. One of these programs is psycmail. This program is intended to be put in your .procmailrc or .forward files to notify you when new mail comes in for your account. It's pretty straightforward. Here is a typical rule to receive email notification from procmail:

:0 hc
|/usr/local/mbin/psycmail psyc://beta.ve.symlynX.com/~user

psycmail is lightweight

psycmail delivers by UDP PSYC. This has a clear strength: UDP is perfectly lightweight - just what procmail needs. And it also has a downside: If your recipient address is not localhost or within the local area network, you may occasionally lose notifications - depending on the quality of the routes inbetween. Or you may even receive no notifications at all, if a router inbetween is filtering such UDP packets. Generally speaking however this is a very good idea.

psycmail uses IP based trust

psycmail currently does no elaborate form of authentication. To appear properly formatted at the recipient's display it however needs a certain degree of trust. This it gets automatically if the sending psycmail and the receiving psyced are on the same host. If this is not the case, you must add the mailer's IP address to the list of trusted hosts - and still the IP should be within your LAN so that you are safe from UDP spoofing.

TODO: Would be better if we added checksums to psycmail, ideally using personal secrets rather than system secrets.

Native PSYC support in procmail

You can improve its performance by compiling this functionality natively right into procmail. To do so you put psycmail.c into the src directory of the procmail distribution, then apply the utility/procmail.patch using patch <procmail.patch. This will produce a version of procmail which allows uniforms as a target address for forwards. So a typical recipe would look like this:

:0 hc
!psyc://beta.ve.symlynX.com/~user

In combination with your server's relay mode also other protocol schemes like XMPP can be specified.

:0 hc
!xmpp:user@jabber.example.net

So if you want Jabber notification straight from your procmailrc, here it is. We do not recommend implementing XMPP natively into procmail as it is by far too complex for the scope of procmail.

To activate the relaying capability you need to specify

PSYCRELAY=psyc://localhost

or an other host running a psyced and configured to trust your mail server. It is correct not to provide a trailing slash, as the server is doing routing duties here - we aren't talking to the server's root object.

TODO: add a PSYCRELAY and PSYCLOG variable to procmail for more flexibility.

Providing PSYC Mail Notification for all your users

Now that procmail can support psycmail natively, you should be able to let your system procmailrc notify all users by the same name on an adjacent PSYC server, or even on a Jabber server once you have a PSYC/XMPP gateway running. Currently there is only one: psyced. But we were thinking of adding some minimal PSYC support to jabberd or ejabberd. What do you think?

Fixing up Postfix for Psycmail

Okay, this should be pretty short and to the point. Feel free to add other methods, improve upon my methods, or whatever. :)

I did not use any sort of local e-mail on the box aside from mail for root. All my e-mail accounts were virtual, and you can't really run virtual accounts through procmail as I had the messages delivered directly to the Maildirs. So, I was presented with two options:

  • Write a filter to filter ALL messages and send appropriate notices to subscribed PSYC users
  • Figure out how to get my e-mails duplicated so they would also be sent to a local account

The first option was really just beyond me. The second option seemed pretty simple, but it became a nightmare due to some of the options necessary in main.cf and master.cf that weren't documented in the default postfix configuration files. So after a lot of help from the #postfix channel on irc.freenode.net (grr, they should be using PSYC too!), I finally figured out how to get it all working.

  • Set up an alias for your address (i.e., mysticone@foxybanana.com) that points to both the virtual address AND a local account (mysticone@foxybanana.com AND mysticone@localhost).
  • Make sure you have home_mailbox commented out. This ensures local mail delivery to /var/spool/mail
  • mailbox_command should = procmail -a "$EXTENSION"
  • append_dot_mydomain = no (I had a big problem with this. My alias pointed to mysticone@localhost, but it kept tacking the value of mydomain to the end of that.)
  • If you're using amavisd or some other filter, make sure to set: "receive_override_options = no_address_mappings" in main.cf, and then "-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks" to master.cf for that particular filter. If you don't have this, you'll get two copies of each message locally.

After doing all this, follow the instructions for psycmail and place it in either your .forward or .procmailrc. When you receive new e-mails, you should get notification on your PSYC user!


<kol_panic> Filter is the key word in "Write a filter to filter ALL messages and send appropriate notices to subscribed PSYC users". You can have amavisd do all of the heavy lifting of managing the SMTP dialog so that your filter script can focus on its job or you can write your own SMTP dialog. Either way, that link is a good resource on how that integrates with Postfix. The short version is that Postfix receives mail, sends it to the after queue content filters then, after filtering, receives it for delivery on a dedicated port for filtered content. Left to the reader, for now, is how to build and submit the delivery notification itself.