eine Ideen ....
1 import smtplib
2 >>> s=smtplib.SMTP("localhost")
3 >>> print s.help()
4 This is Sendmail version 8.8.4
5 Topics:
6 HELO EHLO MAIL RCPT DATA
7 RSET NOOP QUIT HELP VRFY
8 EXPN VERB ETRN DSN
9 For more info use "HELP <topic>".
10 To report bugs in the implementation send email to
11 sendmail-bugs@sendmail.org.
12 For local information send email to Postmaster at your site.
13 End of HELP info
14 >>> s.putcmd("vrfy","someone@here")
15 >>> s.getreply()
16 (250, "Somebody OverHere <somebody@here.my.org>")
17 >>> s.quit()
1 import smtplib
2 import email.Message
3
4 def mail(serverURL=None, sender='', to='', subject='', text=''):
5 message = email.Message.Message()
6 message["To"] = to
7 message["From"] = sender
8 message["Subject"] = subject
9 message.set_payload(text)
10 mailServer = smtplib.SMTP(serverURL)
11 mailServer.sendmail(sender, to, message.as_string())
12 mailServer.quit()
#!text (-)
question: When I create a new mailing list, I don't get the usual
notification E-mail message from Mailman that I know I'm supposed to
get. Instead, I see these log entries in smtp-failure:
Dec 22 21:03:29 2004 (1060) delivery to igueths@lava-net.com failed with code -1: (-2, 'Name or service not known')
Dec 22 21:18:32 2004 (1060) Low level smtp error: (-2, 'Name or service not known'), msgid: <mailman.0.1103765581.1052.mailman@lava-net.com>
Dec 22 21:18:32 2004 (1060) delivery to igueths@lava-net.com failed with code -1: (-2, 'Name or service not known').
What do I do?
answer: It took me an extremely long time to crack this one. The
problem lies in your resolv.conf. What is happening is that Smtplib,
whose subroutines are being called by the
$PREFIX/Mailman/Handlers/SMTPDirect.py script, is unable
to find an FQDN hostname associated with your machine. Therefore, the
exception that is raised by Smtplib is then reflected back in the
smtp-failure log, as demonstrated above. One can see exactly where
the exception is coming from by doing the following at the Python
prompt (this is a transcript of a relevant interactive Python
session):
>>> import smtplib
>>> connection = smtplib.SMTP()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.4/smtplib.py", line 255, in __init__
addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: (-2, 'Name or service not known')
>>>
You will notice that it was the call to SMTP() that ended up failing
to Smtplib, and the call to socket.gethostbyname() that failed inside
the module. The solution to this one believe it or not, is actually
very simple. Add a domain search path to the top of
your resolv.conf, like so:
search my.domain
nameserver 1.2.3.4
nameserver 5.6.7.8
Substitute the above example entries according to your current DNS
configuration. In my case, I run my own domain, with everything
querying my Nameserver directly on localhost. Therefore, my
resolv.conf looks like:
search lava-net.com
nameserver 127.0.0.1
Good luck!
-------------------------------
Note: In the above case, the problem was with resolve.conf, but this exact same symptom can result from other underlying issues. It is sometimes caused by incorrect or incomplete information in /etc/hosts. In at least one reported case it was due to /etc/hosts not being world readable, i.e. 'root' could read it but not 'mailman'.
If the above Python snippet returns the error and you still can't figure out why, try the following:
>>> import socket
>>> x = socket.gethostname()
>>> print x
(response)
>>> y = socket.gethostbyname(x)
>>> print y
(response)
>>>
in order to isolate whether the problem is in getting the local host name, gethostname(), or in getting the IP address from the name, gethostbyname().
If the various diagnostic snippets above don't fail, first make sure you are running them as the 'mailman' user and not as root as this can make a difference. Also see <
. http://mail.python.org/pipermail/mailman-users/2005-May/044972.html> and
. http://mail.python.org/pipermail/mailman-users/2005-May/044742.html>
for more complete tests, and if these work, make sure you don't have different (wrong) settings for SMTPHOST and/or SMTPPORT in mm_cfg.py.
-------------------------------
Note: One more way socket.gethostbyname() can fail is the obvious one,
you haven't set the machine's hostname to an actual fully-qualified
domain name. Mine was still set to the temporary name the machine
had when I installed the OS.
~# hostname
canoworms
~# hostname realname.example.net
~# hostname
realname.example.net
solved the problem and
~# cat /etc/hostname
canoworms
~# echo realname.example.net > /etc/hostname
made it stick.
| /Ablauf /Adressen /Ausbau /Etikette /NachArbeiten /Pflege-der-Daten /email /smtplib /tuning |
Linux/Internet/Mail/Schleuder/smtplib (last modified 2008-11-04 07:00:04)