Simple Email

This is the place for queries that don't fit in any of the other categories.

Simple Email

Postby Swilliams » Tue May 21, 2013 11:20 am

I'm trying to send an email using python, so I followed this -> http://docs.python.org/3/library/email-examples.html
And just changed a few things, and it won't work =[
I'm using IDLE (Python GUI), and that "Firetruck.txt is in C:\Python33\ and it's contents are
"Test

This is a test email for testing, mostly. "

And here's the script and error message I get ->

Code: Select all
>>> import smtplib
>>>
>>> from email.mime.text import MIMEText
>>>
>>> fp = open('Firetruck.txt', 'r')
>>> msg = MIMEText(fp.read())
>>> fp.close()
>>>
>>> msg['Subject'] = 'The contents of %s' % 'Firetruck.txt'
>>> msg['From'] = 'swilliams@brecon-hs.powys.sch.uk'
>>> msg['To'] = 'seanthesuperstar@aol.com'
>>>
>>> s = smtplib.SMTP('BHS-MAIL')
>>> s.send_message(msg)
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    s.send_message(msg)
  File "C:\Python33\lib\smtplib.py", line 835, in send_message
    rcpt_options)
  File "C:\Python33\lib\smtplib.py", line 773, in sendmail
    raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'seanthesuperstar@aol.com': (550, b'5.7.1 Unable to relay')}
>>> s.send_message(msg)
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    s.send_message(msg)
  File "C:\Python33\lib\smtplib.py", line 835, in send_message
    rcpt_options)
  File "C:\Python33\lib\smtplib.py", line 773, in sendmail
    raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'seanthesuperstar@aol.com': (550, b'5.7.1 Unable to relay')}
Swilliams
 
Posts: 4
Joined: Tue May 21, 2013 11:10 am

Re: Simple Email

Postby Kebap » Tue May 21, 2013 12:10 pm

Hi and welcome to the forums!

Please use code tags, as explained in the sticky thread.

Then, did you make sure you are actually allowed to relay SMTP mails there? Maybe talk with your admin.

Swilliams wrote:I'm trying to send an email using python, so I followed this -> http://docs.python.org/3/library/email-examples.html
And just changed a few things, and it won't work =[
I'm using IDLE (Python GUI), and that "Firetruck.txt is in C:\Python33\ and it's contents are
"Test

This is a test email for testing, mostly. "

And here's the script and error message I get ->

Code: Select all
>>> import smtplib
>>>
>>> from email.mime.text import MIMEText
>>>
>>> fp = open('Firetruck.txt', 'r')
>>> msg = MIMEText(fp.read())
>>> fp.close()
>>>
>>> msg['Subject'] = 'The contents of %s' % 'Firetruck.txt'
>>> msg['From'] = 'swilliams@brecon-hs.powys.sch.uk'
>>> msg['To'] = 'seanthesuperstar@aol.com'
>>>
>>> s = smtplib.SMTP('BHS-MAIL')
>>> s.send_message(msg)
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    s.send_message(msg)
  File "C:\Python33\lib\smtplib.py", line 835, in send_message
    rcpt_options)
  File "C:\Python33\lib\smtplib.py", line 773, in sendmail
    raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'seanthesuperstar@aol.com': (550, b'5.7.1 Unable to relay')}
>>> s.send_message(msg)
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    s.send_message(msg)
  File "C:\Python33\lib\smtplib.py", line 835, in send_message
    rcpt_options)
  File "C:\Python33\lib\smtplib.py", line 773, in sendmail
    raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'seanthesuperstar@aol.com': (550, b'5.7.1 Unable to relay')}
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 366
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: Simple Email

Postby Swilliams » Tue May 21, 2013 12:19 pm

Thank you ^_^

I'm sorry, I should've read before posting :c

And I'm not sure, how would I enable that?

Or is there some other way of doing it?
Swilliams
 
Posts: 4
Joined: Tue May 21, 2013 11:10 am

Re: Simple Email

Postby Swilliams » Tue May 21, 2013 1:25 pm

It turns out I only have permission to send to addresses on that server, which is all I really needed =]
Swilliams
 
Posts: 4
Joined: Tue May 21, 2013 11:10 am


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests