Ian Bicking wrote:
> The problem isn't specific to EmailForward, I don't think -- it's only
> that EmailForward imports from a location you haven't tried before.
> 
> I'd try moving EmailForward.py to another context that is working, and
> see what happens then.

Okay, issues:

1) The innocuous open('/tmp/out1','w').write(...)
in EmailAdapter.py is a problem if you check the
script as one user (root) and run mail as another
(mail), since mail can't overwrite it. For some
reason I couldn't get any error messages that told
me this, I just figured it out finally.

2) EmailAdapter.py seems to require something like:

        if __name__ == '__main__':
                main("/usr/local/src/Webware/WebKit")

to run. In my case, I just untarred EmailKit as
'/usr/local/src/Webware/EmailKit'.

3) sendmail requires a link from /etc/smrsh to the
Python program being run. In my case, I did:

        cd /etc/smrsh
        ln usr/local/src/Webware/EmailKit/EmailAdaptor.py

EmailAdaptor.py of course needs to be executable by
the mail program - something like:

        chown mail.mail EmailAdaptor.py
        chmod u+x EmailAdaptor.py

The line in /etc/alias would then look something like:

xmail: "|/usr/local/src/Webware/EmailKit/EmailAdaptor.py /Emax/EForward

where Emax is a context I threw into WebKit/Configs/Application.config
pointing to Webware/EmailKit/Examples, and EForward.py is my actual
forwarding script.

I tested sendmail with "mail -v xmail" - if the EmailAdaptor.py
script failed for any reason, sendmail would just give a
"service not available" error and chuck it into dead.letter.
But just exiting with sys.exit() before any errors occur gives
it a normal delivery message, so you can just push back the
exit statement to debug.

4) The EmailServlet class has an error:

        def responseToEmail(self):
                raise SubclassResponsibilityError

should be:

        def respondToEmail(self):
                raise SubclassResponsibilityError

though since the subclass (EmailForward.py) creates
a "respondToEmail" method, it doesn't appear to have
an effect.

5) I had to adjust the path in EForward.py to
find the EmailServlet class, in this case:

sys.path.insert(1,"..")

6) I rewrote the Email handler to be:

      def respondToEmail(self):
         try:
                 addr_to = ['bill']
                 addr_from = '[EMAIL PROTECTED]'
                 msg="To: %s\nFrom: %s\n\n%s\n\n" % 
(addr_to[0],addr_from,self.fullEmail())

                 open('/tmp/respondtoEmail','w').write(msg)

                 myserver = smtplib.SMTP('localhost')
                 myserver.sendmail(addr_from,addr_to, msg)
                 myserver.quit()

         except Exception,e:
                 open('/tmp/responseError','w').write("Error: %s" % (e))


The "To field here is a list (it works fine as a string),
and for my sendmail configuration, a From: without a domainname
(say: "unknown" instead of "unknown@localhost") is rejected,
which shows up in /var/log/maillog.

7) It also made it clearer for me to override the respond methods
from HTTPServlet and others in superclasses to find out what was
happening at earlier stages in the servlet handshaking.

-- 
Bill Eldridge
Radio Free Asia
[EMAIL PROTECTED]



_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to