Another try:

Morten Trab wrote:
Hi,

When trying to send an email using TMDA-ofmipd I just get the following
error:

Error: failure delivering message to command "['/usr/bin/tmda-inject',
'[EMAIL PROTECTED]']" (command "['/usr/bin/tmda-inject',
'[EMAIL PROTECTED]']" exited 1  (Traceback (most recent call last):
  File "/usr/bin/tmda-inject", line 123, in ?
    from TMDA import Cookie
  File "/usr/lib/python2.2/site-packages/TMDA/Cookie.py", line 30, in ?
    import Defaults
  File "/usr/lib/python2.2/site-packages/TMDA/Defaults.py", line 68, in ?
    execfile(GLOBAL_TMDARC)
  File "/etc/tmdarc", line 16, in ?
    PENDING_DIR = "/home/vmail/%s/%s/Maildir/.tmda/pending/" %
(os.environ["HOSTn"],os.environ["USERn"])
  File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
KeyError: HOSTn))
Data: 'QUIT'

I’ve tried to export the USERn and HOSTn vars using the vpopmail-vdir script
(a modified version) which is looking like this:

#!/bin/bash
echo "/home/vmail/$2/$1/Maildir"

USERn=$1
HOSTn=$2

export USERn
export HOSTn

The command I use to start tmda-ofmipd is:

su - vmail -c "tmda-ofmipd -R imap -f -d -S /usr/bin/vpopmail-vdir.sh"

How can I successfully get those two vars (USERn and HOSTn) exported so
tmda-inject can read them??

You can't for the reasons I explained before.

However, it looks like TMDA sets the HOME environment variable based off what your -S script prints out (line 1221 of my copy of tmda-ofmipd).

Thus, in your /etc/tmdarc, instead of relying on HOSTn and USERn to setup the full path to the pending dir, just do this:

PENDING_DIR = ~Maildir/.tmda/pending/

tmda-ofmip will expand the ~ to whatever you -S script returned, and it will all work out.

The problem you'll then run into is when your MTA runs TMDA to deliver mail, perhaps HOME isn't set, but USERn and HOSTn are, and you expect tmdarc to calculate your file/directory locations based off these?

To solve this, you probably want something like this in your /etc/tmdarc:

if os.environ.has_key('HOSTn') and os.environ.has_key('USERn'):
    os.environ['HOME'] = "/home/vmail/%s/%s" % \
        (os.environ["HOSTn"],os.environ["USERn"])
#

This way, if HOSTn/USERn are set (MTA case), then HOME is calculated based off them, but if they aren't set (tmda-ofmipd case), /etc/tmdarc will rely on tmda-ofmipd having setup the HOME environment variable based on the results from your -S script.

Note - you'll have to ensure that simply writing to os.environ['HOME'] is picked up by TMDA's ~ expansion code - I don't know if TMDA caches the value of HOME at startup, or whether it reads from the environment each time. This'll be something in $tmda_root/TMDA/Util.py I expect.

Hope this helps more!
_____________________________________________
tmda-users mailing list ([email protected])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to