rhuffman8 0 Light Poster

I want to be able to write a Python script to send a text message to a user's phone using an email client. I have tried the following code:

import smtplib

from email.mime.text import MIMEText

msg = MIMEText('message')

msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = 'example@mail.examplecompany.net'
msg['To'] = '0000000000@txt.att.net'

s = smtplib.SMTP('mail.examplecompany.net', 25)
s.sendmail(me, [you], msg.as_string())

and ran into the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python26\lib\smtplib.py", line 709, in sendmail raise STMPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'0000000000@txt.att.net': (550, '<0000000000@txt.att.net> No such user here')}

which led me to believe the function was looking for recipient address on the same host as the sender/the host being used. So, I also tried the following code, using the Gmail server:

server = smtplib.SMTP('smtp.gmail.com:587')  
server.sendmail(fromaddr, toaddrs, msg)  

and was able to send the message to my phone.
Am I able to use the company host and my email address on that server or is there something wrong with my logic there? Why does this work with Gmail but not our server?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.