Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77423 > unrolled thread

Re:error while writing program to send mail.

Started byDave Angel <davea@davea.name>
First post2014-09-01 20:02 -0400
Last post2014-09-01 20:02 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re:error while writing program to send mail. Dave Angel <davea@davea.name> - 2014-09-01 20:02 -0400

#77423 — Re:error while writing program to send mail.

FromDave Angel <davea@davea.name>
Date2014-09-01 20:02 -0400
SubjectRe:error while writing program to send mail.
Message-ID<mailman.13702.1409616038.18130.python-list@python.org>
Om Prakash <torque.india@gmail.com> Wrote in message:
> Hi,
> 
> I am writing this program from 
> https://docs.python.org/2/library/email-examples.html
> 
> but getting the error as
> 
> singhom@debian:~/pythons$ python send_email.py
> Traceback (most recent call last):
>    File "send_email.py", line 18, in <module>
>      msg['Subject']  = 'The contents of $s' % message
> NameError: name 'message' is not defined
> 
> 
> i know the error would be something simple and i am overlooking it, any 
> help would be highly appreciated, I am sorry, but I am very new to 
> python programming.
> 
> code starts here.
> #/usr/bin/python2.7 -tt
> 
> ## sending a simple text message using python.
> import smtplib
> 
> from email.mime.text import MIMEText
> 
> # Open file for reading.
> fp = open("message", 'rb')
> # Create a plain text message.
> msg = MIMEText(fp.read())
> 
> fp.close

This line doesn't do anything.  If you want to close the file, 
 you need some parens,  Or you can use the 'with' form instead of
 open.

> 
> me = "torque.india@gmail.com"
> you = "oomprakash@gmail.com"
> 
> msg['Subject']  = 'The contents of $s' % message

Just what did you plan to use here? You never defined a variable
 called message. If you intended to use msg, I presume you realize
 it could be quite large,



-- 
DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web