[Zope] sendmail

Martijn Pieters mj@digicool.com
Thu, 21 Sep 2000 10:01:46 +0200


On Tue, Sep 19, 2000 at 09:05:12AM -0400, Jason Cunliffe wrote:
> ----- Original Message -----
> From: J. Atwood <jatwood@bwanazulia.com>
> 
> 
> > It looks like the email address you are sending (testing) to is not valid.
> >
> > "host not found"
> 
> That can't be right. I have tried with a couple of known working email
> address.
> ..But I notice the Python error points first to /lib/python1.5/ and then
> /lib/python
> 
> What up? Is this 'normal' for Zope 2.2.x?
> 
> File /Zope-2.2.0/lib/python/Products/MailHost/MailHost.py, line 220, in send
> (Object: dolphinsMailHost)
> File /Zope-2.2.0/lib/python1.5/smtplib.py, line 452, in sendmail
> File /Zope-2.2.0/lib/python1.5/smtplib.py, line 303, in ehlo

In a Zope binary install, Python 1.5.2 is included; it's library files are
in lib/python1.5/. Zope's own modules are in lib/python. smtplib.py is a
standard Python module and is thus pulled from the python lib directory.

> > At 7:10 AM -0400 9/19/2000, Jason Cunliffe wrote:
> > >Hello
> > >
> > >Trying to automate some sendmail messages
> > >but we keep getting
> > >
> > >Error Type: error
> > >Error Value: host not found

<SNIP ...>

> > >   File /Zope-2.2.0/lib/python1.5/smtplib.py, line 452, in sendmail
> > >   File /Zope-2.2.0/lib/python1.5/smtplib.py, line 303, in ehlo
> > >error: (see above)
> > >
> > >Any clues to what is wrng here?

From the source of smtplib.py:

    """ SMTP 'ehlo' command.
    Hostname to send for this command defaults to the FQDN of the local
    host.
    """

smtpib first tries to send a 'EHLO' command to see if the server supports
extended SMTP commands. But it will have to send the hostname of the
machine from which you are contacting the SMTP server along. This is where
things go wrong (line 303):

    name=socket.gethostbyaddr(socket.gethostname())[0]

The above line _should_ return your Fully Qualified Domain Name. But the
result of socket.gethostname() isn't resolvable into a full host
specification; thus resulting in the 'host not found' message.

I *think* that socket.gethostname() returns exactly the same result as
'hostname' on the commandline does. You may want to check that in a python
interpreter (python<CR> import socket<CR> socket.gethostname()<CR>).

You can use the same command (hostname) as root to set the correct
hostname, or you will have to make sure your hostname is resolvable into
an ip-address (edit /etc/hosts should do that I think).

To illustrate, the output of the command
socket.gethostbyaddr(socket.gethostname()) on my machine results in:

  ('localhost', ['sneek'], ['127.0.0.1'])

which matches nicely with the following entry in /etc/hosts:

  127.0.0.1	localhost sneek

Hope this helps.

-- 
Martijn Pieters
| Software Engineer  mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------