Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Problem w/ smtplib

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


victorsubervi at gmail

Nov 21, 2009, 5:19 AM

Post #1 of 5 (333 views)
Permalink
Problem w/ smtplib

Hi;
I get the following error:

/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py 52
session.sendmail(clientEmail, ourEmail1, header+msg)
53 # session.sendmail(clientEmail, ourEmail2, header+msg)
54
55 mailSpreadsheet()
56
*mailSpreadsheet* = <function mailSpreadsheet>
/var/www/html/globalsolutionsgroup.vi/mailSpreadsheet.py in *mailSpreadsheet
*() 47 order += 'TOTAL: $' + str(total)
48
msg = 'Here is the order from %s:\n\n %s' % (string.replace(client,
'_', ' '), order)
49 session = smtplib.SMTP("localhost")
50 session.login(user, passwd) # only if it requires auth
51
header = "Subject: %s \r\nContent-type: text/html;
charset=utf-8\r\n\r\n" % subject
session *undefined*, *global* *smtplib* = <module 'smtplib' from
'/usr/lib64/python2.4/smtplib.pyc'>, smtplib.*SMTP* = <class smtplib.SMTP>
/usr/lib64/python2.4/smtplib.py in *__init__*(self=<smtplib.SMTP instance>,
host='localhost', port=0, local_hostname=None) 242
self.esmtp_features = {}
243 if host:
244 (code, msg) = self.connect(host, port)
245 if code != 220:
246 raise SMTPConnectError(code, msg)
code *undefined*, msg *undefined*, *self* = <smtplib.SMTP instance>, self.*
connect* = <bound method SMTP.connect of <smtplib.SMTP instance>>, *host* =
'localhost', *port* = 0 /usr/lib64/python2.4/smtplib.py in
*connect*(self=<smtplib.SMTP
instance>, host='localhost', port=25) 305 if not self.sock:
306 raise socket.error, msg
307 (code, msg) = self.getreply()
308 if self.debuglevel > 0: print>>stderr, "connect:", msg
309 return (code, msg)
code *undefined*, *msg* = 'getaddrinfo returns an empty list', *self* =
<smtplib.SMTP instance>, self.*getreply* = <bound method SMTP.getreply of
<smtplib.SMTP instance>> /usr/lib64/python2.4/smtplib.py in
*getreply*(self=<smtplib.SMTP
instance>) 349 if line == '':
350 self.close()
351
raise SMTPServerDisconnected("Connection unexpectedly closed")
352
if self.debuglevel > 0: print>>stderr, 'reply:', repr(line)
353 resp.append(line[4:].strip())
*global* *SMTPServerDisconnected* = <class smtplib.SMTPServerDisconnected>*
SMTPServerDisconnected*: Connection unexpectedly closed
args = ('Connection unexpectedly closed',)

Why did this connection close? How do I fix it? I tried commenting out the
authentication line. I have imported smtplib.
TIA,
Victor


kevin.p.dwyer at gmail

Nov 21, 2009, 9:04 AM

Post #2 of 5 (311 views)
Permalink
Re: Problem w/ smtplib [In reply to]

On Sat, 21 Nov 2009 08:19:52 -0500, Victor Subervi wrote:

Hello Victor,

The information that you have sent comes from the client side of the
transaction, so it isn't possible to tell why the server disconnected.
Assuming that there is an SMTP server listening on port 25, you need to
check the SMTP server logs. You might need to crank up the logging to
get useful output.

If the information that you pasted in comes from a Django traceback then
you could check the Django page on e-mail at
http://docs.djangoproject.com/en/dev/topics/email/#topics-email
(dev version, you might need to view an older version).

Cheers,

Kev

--
http://mail.python.org/mailman/listinfo/python-list


victorsubervi at gmail

Nov 21, 2009, 9:27 AM

Post #3 of 5 (311 views)
Permalink
Re: Problem w/ smtplib [In reply to]

On Sat, Nov 21, 2009 at 12:04 PM, Kev Dwyer <kevin.p.dwyer [at] gmail> wrote:

> On Sat, 21 Nov 2009 08:19:52 -0500, Victor Subervi wrote:
>
> Hello Victor,
>
> The information that you have sent comes from the client side of the
> transaction, so it isn't possible to tell why the server disconnected.
> Assuming that there is an SMTP server listening on port 25, you need to
> check the SMTP server logs.


There wasn't anything in /var/log/maillog. Is that where I should have
checked?


> You might need to crank up the logging to
> get useful output.
>

How?
Look at the output below:

[root [at] 13gem stcroixresort]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 *:mysql *:*
LISTEN 24488/mysqld
tcp 0 0 *:pop3 *:*
LISTEN 5278/tcpserver
tcp 0 0 *:ftp *:*
LISTEN 26564/vsftpd
tcp 0 0 localhost.localdomai:domain *:*
LISTEN 11845/named
tcp 0 0 *:smtp *:*
LISTEN 5274/tcpserver
tcp 0 0 localhost.localdomain:rndc *:*
LISTEN 11845/named
tcp 0 0 *:http *:*
LISTEN 5201/httpd
tcp 0 0 localhost:domain *:*
LISTEN 11845/named
tcp 0 0 *:ssh *:*
LISTEN 15509/sshd
tcp 0 0 localhost:rndc *:*
LISTEN 11845/named
udp 0 0 localhost.locald:domain
*:* 11845/named
udp 0 0 localhost:domain
*:* 11845/named
[root [at] 13gem stcroixresort]# qmailctl stat
/service/qmail-send: up (pid 5266) 594565 seconds
/service/qmail-send/log: up (pid 5271) 594565 seconds
/service/qmail-smtpd: up (pid 5274) 594565 seconds
/service/qmail-smtpd/log: up (pid 5276) 594565 seconds
/service/qmail-pop3d: up (pid 5278) 594565 seconds
/service/qmail-pop3d/log: up (pid 5279) 594565 seconds
messages in queue: 0
messages in queue but not yet preprocessed: 0

Please advise.
TIA,
V


kevin.p.dwyer at gmail

Nov 21, 2009, 10:16 AM

Post #4 of 5 (312 views)
Permalink
Re: Problem w/ smtplib [In reply to]

2009/11/21 Victor Subervi <victorsubervi [at] gmail>

> On Sat, Nov 21, 2009 at 12:04 PM, Kev Dwyer <kevin.p.dwyer [at] gmail>wrote:
>
>> On Sat, 21 Nov 2009 08:19:52 -0500, Victor Subervi wrote:
>>
>> Hello Victor,
>>
>> The information that you have sent comes from the client side of the
>> transaction, so it isn't possible to tell why the server disconnected.
>> Assuming that there is an SMTP server listening on port 25, you need to
>> check the SMTP server logs.
>
>
> There wasn't anything in /var/log/maillog. Is that where I should have
> checked?
>
>
>> You might need to crank up the logging to
>> get useful output.
>>
>
> How?
> Look at the output below:
>
> [root [at] 13gem stcroixresort]# netstat -tulp
> Active Internet connections (only servers)
> Proto Recv-Q Send-Q Local Address Foreign Address
> State PID/Program name
> tcp 0 0 *:mysql *:*
> LISTEN 24488/mysqld
> tcp 0 0 *:pop3 *:*
> LISTEN 5278/tcpserver
> tcp 0 0 *:ftp *:*
> LISTEN 26564/vsftpd
> tcp 0 0 localhost.localdomai:domain *:*
> LISTEN 11845/named
> tcp 0 0 *:smtp *:*
> LISTEN 5274/tcpserver
> tcp 0 0 localhost.localdomain:rndc *:*
> LISTEN 11845/named
> tcp 0 0 *:http *:*
> LISTEN 5201/httpd
> tcp 0 0 localhost:domain *:*
> LISTEN 11845/named
> tcp 0 0 *:ssh *:*
> LISTEN 15509/sshd
> tcp 0 0 localhost:rndc *:*
> LISTEN 11845/named
> udp 0 0 localhost.locald:domain
> *:* 11845/named
> udp 0 0 localhost:domain
> *:* 11845/named
> [root [at] 13gem stcroixresort]# qmailctl stat
> /service/qmail-send: up (pid 5266) 594565 seconds
> /service/qmail-send/log: up (pid 5271) 594565 seconds
> /service/qmail-smtpd: up (pid 5274) 594565 seconds
> /service/qmail-smtpd/log: up (pid 5276) 594565 seconds
> /service/qmail-pop3d: up (pid 5278) 594565 seconds
> /service/qmail-pop3d/log: up (pid 5279) 594565 seconds
> messages in queue: 0
> messages in queue but not yet preprocessed: 0
>
> Please advise.
> TIA,
> V
>

Hello Victor,

I'm afraid I don't know much about mail servers, you need to check the
server docs or ask on a qmail mailing list.

If you really think this is a python issue, then you could try:
>>> import smtplib
>>> server = smtplib.SMTP()
>>> server.set_debuglevel(1)
>>> server.connect()
connect: ('localhost', 25)
connect: (25, 'localhost')
reply: '220 pluto.site ESMTP Postfix\r\n'
reply: retcode (220); Msg: pluto.site ESMTP Postfix
connect: pluto.site ESMTP Postfix
(220, 'pluto.site ESMTP Postfix')
>>> server.quit()
send: 'quit\r\n'
reply: '221 2.0.0 Bye\r\n'
reply: retcode (221); Msg: 2.0.0 Bye
(221, '2.0.0 Bye')


and see if there are any error messages/tracebacks in the output; but if you
still get a disconnect exception then it's unlikely that this is a python
issue.

Cheers,

Kev


victorsubervi at gmail

Nov 21, 2009, 10:59 AM

Post #5 of 5 (311 views)
Permalink
Re: Problem w/ smtplib [In reply to]

On Sat, Nov 21, 2009 at 1:16 PM, Kev Dwyer <kevin.p.dwyer [at] gmail> wrote:

>
> 2009/11/21 Victor Subervi <victorsubervi [at] gmail>
>
> On Sat, Nov 21, 2009 at 12:04 PM, Kev Dwyer <kevin.p.dwyer [at] gmail>wrote:
>>
>>> On Sat, 21 Nov 2009 08:19:52 -0500, Victor Subervi wrote:
>>>
>>> Hello Victor,
>>>
>>> The information that you have sent comes from the client side of the
>>> transaction, so it isn't possible to tell why the server disconnected.
>>> Assuming that there is an SMTP server listening on port 25, you need to
>>> check the SMTP server logs.
>>
>>
>> There wasn't anything in /var/log/maillog. Is that where I should have
>> checked?
>>
>>
>>> You might need to crank up the logging to
>>> get useful output.
>>>
>>
>> How?
>> Look at the output below:
>>
>> [root [at] 13gem stcroixresort]# netstat -tulp
>> Active Internet connections (only servers)
>> Proto Recv-Q Send-Q Local Address Foreign
>> Address State PID/Program name
>> tcp 0 0 *:mysql
>> *:* LISTEN 24488/mysqld
>> tcp 0 0 *:pop3
>> *:* LISTEN 5278/tcpserver
>> tcp 0 0 *:ftp
>> *:* LISTEN 26564/vsftpd
>> tcp 0 0 localhost.localdomai:domain
>> *:* LISTEN 11845/named
>> tcp 0 0 *:smtp
>> *:* LISTEN 5274/tcpserver
>> tcp 0 0 localhost.localdomain:rndc
>> *:* LISTEN 11845/named
>> tcp 0 0 *:http
>> *:* LISTEN 5201/httpd
>> tcp 0 0 localhost:domain
>> *:* LISTEN 11845/named
>> tcp 0 0 *:ssh
>> *:* LISTEN 15509/sshd
>> tcp 0 0 localhost:rndc
>> *:* LISTEN 11845/named
>> udp 0 0 localhost.locald:domain
>> *:* 11845/named
>> udp 0 0 localhost:domain
>> *:* 11845/named
>> [root [at] 13gem stcroixresort]# qmailctl stat
>> /service/qmail-send: up (pid 5266) 594565 seconds
>> /service/qmail-send/log: up (pid 5271) 594565 seconds
>> /service/qmail-smtpd: up (pid 5274) 594565 seconds
>> /service/qmail-smtpd/log: up (pid 5276) 594565 seconds
>> /service/qmail-pop3d: up (pid 5278) 594565 seconds
>> /service/qmail-pop3d/log: up (pid 5279) 594565 seconds
>> messages in queue: 0
>> messages in queue but not yet preprocessed: 0
>>
>> Please advise.
>> TIA,
>> V
>>
>
> Hello Victor,
>
> I'm afraid I don't know much about mail servers, you need to check the
> server docs or ask on a qmail mailing list.
>
> If you really think this is a python issue, then you could try:
> >>> import smtplib
> >>> server = smtplib.SMTP()
> >>> server.set_debuglevel(1)
> >>> server.connect()
> connect: ('localhost', 25)
> connect: (25, 'localhost')
> reply: '220 pluto.site ESMTP Postfix\r\n'
> reply: retcode (220); Msg: pluto.site ESMTP Postfix
> connect: pluto.site ESMTP Postfix
> (220, 'pluto.site ESMTP Postfix')
> >>> server.quit()
> send: 'quit\r\n'
> reply: '221 2.0.0 Bye\r\n'
> reply: retcode (221); Msg: 2.0.0 Bye
> (221, '2.0.0 Bye')
>
>
> and see if there are any error messages/tracebacks in the output; but if
> you still get a disconnect exception then it's unlikely that this is a
> python issue.
>

Thank you. Yes, there was an error.
V

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.