By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

Python cannot use SMTP...

P: n/a
JZ
I cannot find out what is the problem with my Python. I cannot join to smtp
host.
python

Python 2.3.4 (#1, Jun 22 2004, 04:42:42)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import smtplib
smtplib.SMTP('localhost')

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/smtplib.py", line 242, in __init__
raise SMTPConnectError(code, msg)
smtplib.SMTPConnectError: (-1, "onnect: failed to connect to database:
Error: Access denied for user: 'admin@localhost' (Using password: YES)")

The same problem appears in Plone 2.0.4. I cannot send any emails because
of it and I do not know how to sove it.

I checked PHP scripts on the same linux box, but it works fine. Only Python
has the problem...

--
JZ
Jul 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
JZ wrote:
I cannot find out what is the problem with my Python. I cannot join to smtp
host.
python


Python 2.3.4 (#1, Jun 22 2004, 04:42:42)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import smtplib
smtplib.SMTP('localhost')


Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/smtplib.py", line 242, in __init__
raise SMTPConnectError(code, msg)
smtplib.SMTPConnectError: (-1, "onnect: failed to connect to database:
Error: Access denied for user: 'admin@localhost' (Using password: YES)")


This appears to be because your server is responding in a non-standard
way. The "-1" arises because an improperly formed SMTP response line
was received.

Try connecting using telnet ("telnet localhost 25") and see what you
get. It should look something like the first line here:

220 some.host.name blah blah blah

The first three characters are the critical part. If they aren't
a three-digit SMTP response code, your server is likely borken.
If you post the results, someone might have some advice, but it's
not likely this is a Python issue.

-Peter
Jul 18 '05 #2

P: n/a
JZ
Wed, 01 Sep 2004 08:33:51 -0400, na comp.lang.python, Peter Hansen
napisa³(a):
The first three characters are the critical part. If they aren't
a three-digit SMTP response code, your server is likely borken.
If you post the results, someone might have some advice, but it's
not likely this is a Python issue.


via telnet localhost 25:
....
Connected to localhost.
Escape character is '^]'.
db_connect: failed to connect to database: Error: Access denied for user:
'admin@localhost' (Using password: YES)
220 NS1.4U2.PL ESMTP

Strange, because I can send emails from bash using mail command. I can send
email with php scripts as well (using mail() function). php.ini file has
empty settings for SMTP, so it uses default system settings...

--
JZ

Jul 18 '05 #3

P: n/a

On 1-sep-04, at 14:56, JZ wrote:
Wed, 01 Sep 2004 08:33:51 -0400, na comp.lang.python, Peter Hansen
napisa©©(a):
The first three characters are the critical part. If they aren't
a three-digit SMTP response code, your server is likely borken.
If you post the results, someone might have some advice, but it's
not likely this is a Python issue.


via telnet localhost 25:
...
Connected to localhost.
Escape character is '^]'.
db_connect: failed to connect to database: Error: Access denied for
user:
'admin@localhost' (Using password: YES)
220 NS1.4U2.PL ESMTP


This is a buggy mail server, the line starting with 'db_connect' is not
according to spec.

If other tools work that is coincidence.

Ronald
Jul 18 '05 #4

P: n/a
JZ wrote:
Wed, 01 Sep 2004 08:33:51 -0400, na comp.lang.python, Peter Hansen
napisa³(a):
The first three characters are the critical part. If they aren't
a three-digit SMTP response code, your server is likely borken.
If you post the results, someone might have some advice, but it's
not likely this is a Python issue.


via telnet localhost 25:
...
Connected to localhost.
Escape character is '^]'.
db_connect: failed to connect to database: Error: Access denied for user:
'admin@localhost' (Using password: YES)
220 NS1.4U2.PL ESMTP

Strange, because I can send emails from bash using mail command. I can send
email with php scripts as well (using mail() function). php.ini file has
empty settings for SMTP, so it uses default system settings...


I expect other tools are being more lenient, ignoring each line that
doesn't look like a proper SMTP reply until they find one that does.
That doesn't mean the smtplib approach is wrong, mind you...

It would be pretty easy to hack your local smtplib.py to skip over that
junk, if you were so inclined.

Probably even easier just to fix the server...

-Peter
Jul 18 '05 #5

P: n/a
JZ wrote:
smtplib.SMTPConnectError: (-1, "onnect: failed to connect to database:
Error: Access denied for user: 'admin@localhost' (Using password: YES)")


That a MySQL error. I don't kwon how you made this error apear in your STMP
connection, I can only guess:
Does your STMP server any MySQL authentication?
Are you running MySQL on port 25?

Maybe the right of your mail log and a the result of
"netstat -nlp -A inet"
would help us to find the problem.

Thomas
Jul 18 '05 #6

P: n/a
JZ
Wed, 01 Sep 2004 15:45:55 +0200, na comp.lang.python, Thomas Krüger wrote:
smtplib.SMTPConnectError: (-1, "onnect: failed to connect to database:
Error: Access denied for user: 'admin@localhost' (Using password: YES)")
That a MySQL error. I don't kwon how you made this error apear in your STMP
connection, I can only guess:
Does your STMP server any MySQL authentication?


I am not sure. I do not know if it is important but I am using VPS (virtual
computer) hosting. And I did not install sendmail. It was installed as I
got it.
Are you running MySQL on port 25?
No, it works on standard port 3306.
Maybe the right of your mail log and a the result of
"netstat -nlp -A inet"
would help us to find the problem.


Here is the result:

[root@xeon lib]# netstat -nlp -A inet
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 216.93.188.184:20000 0.0.0.0:* LISTEN
5912/perl
tcp 0 0 216.93.188.184:199 0.0.0.0:* LISTEN
4648/snmpd
tcp 0 0 216.93.188.184:3306 0.0.0.0:* LISTEN
20595/mysqld
tcp 0 0 216.93.188.184:10000 0.0.0.0:* LISTEN
6339/perl
tcp 0 0 216.93.188.184:8080 0.0.0.0:* LISTEN
4113/python
tcp 0 0 216.93.188.184:80 0.0.0.0:* LISTEN
20390/httpd
tcp 0 0 216.93.188.184:21 0.0.0.0:* LISTEN
7910/xinetd
tcp 0 0 216.93.188.184:8021 0.0.0.0:* LISTEN
4113/python
tcp 0 0 216.93.188.184:22 0.0.0.0:* LISTEN
17856/sshd
tcp 0 0 216.93.188.184:8280 0.0.0.0:* LISTEN
4113/python
tcp 0 0 216.93.188.184:25 0.0.0.0:* LISTEN
7910/xinetd
udp 0 0 216.93.188.184:10000 0.0.0.0:*
6339/perl
udp 0 0 216.93.188.184:20000 0.0.0.0:*
5912/perl
udp 0 0 216.93.188.184:161 0.0.0.0:*
4648/snmpd

--
JZ
Jul 18 '05 #7

P: n/a
JZ wrote:
tcp 0 0 216.93.188.184:25 0.0.0.0:* LISTEN
7910/xinetd


Port 25 is handled by the xinetd. There may be a wrapper around it.
What program will be started on connetion to port 25?
See the /etc/xinet.d/ folder to find it out.

You may also try to send mail to 216.93.188.184 instead of localhost

Thomas
Jul 18 '05 #8

P: n/a
JZ
Wed, 01 Sep 2004 17:17:15 +0200, na comp.lang.python, Thomas Krüger
napisa³(a):
See the /etc/xinet.d/ folder to find it out.
It is wrapped with strange soft.
You may also try to send mail to 216.93.188.184 instead of localhost


Without results. I found other solution. I changed smtp to other host and
it helped.

--
JZ
Jul 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.