I'm trying to send an email (via a contact form) on my Godaddy shared hosting account (I know!). I've simplified it for the purposes of getting it working. I have SSH access. The script is located in my cgi-bin folder. The from email address is a Godaddy domain one (required apparently). I have it working on my test home server (using gmail's smtp server).
#! /usr/bin/python
import smtplib
import string, sys
import cgitb
cgitb.enable()
sys.stderr = sys.stdout
print 'Content-Type: text/plain'
print
HOST = "relay-hosting.secureserver.net"
FROM = "myemail@mygodaddydomain.co.uk"
TO = "mygmail@gmail.com"
SUBJECT = "Test"
BODY = "Hello"
body = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"",
BODY), "\r\n")
print body
server = smtplib.SMTP(HOST, 25)
server.sendmail(FROM, [TO], body)
I'm getting the following error:
Traceback (most recent call last):
File "test2.py", line 28, in <module>
server = smtplib.SMTP(HOST, 25)
File "/usr/lib64/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib64/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib64/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib64/python2.6/socket.py", line 567, in create_connection
raise error, msg
error: [Errno 110] Connection timed out
I've been told the Godaddy smtp server settings are correct and have tried a few combinations reading other similar questions on Stackoverflow.