Problem using smtplib.SMTP in a CGI program

Martin Bless mb at muenster.de
Fri Mar 19 14:11:23 EST 2004


[dfh at forestfield.co.uk (David Hughes)]:

>SMTPhost = auth.smtp.oneandone.co.uk
[...]
>socket.error: (111, 'Connection refused')
>
>The value of SMTPhost is the one my ISP adviced me to use, it is an 
>authenticated server requiring a user name and password and I can access 
>it using Microsoft Outlook Express without difficulty.

I don't know about 'www.oneandone.co.uk' but I know what helped 
at 'www.1und1.de'. The problem is that they simply don't allow 
smtp-access from within.

On http://faq.1und1.de/hosting/skripte_datenbanken/python/3.html 1und1
advises you to use:

#!/usr/bin/python
import os
print "Content-Type: text/plain"
print
Mailto= "empfaenger at musterfrau.de"
Mailfrom = "absender at musterfrau.de"
Subject = "Betreff"
Header = """From: %s
To: %s
Subject: %s
""" % (Mailfrom, Mailto, Subject)
msg = Header + " Dies ist eine Test-Mail "
sendmail = os.popen("/usr/lib/sendmail -t", "w")
sendmail.write(msg)
sendmail.close()

hope this helps,

mb - Martin Bless




More information about the Python-list mailing list