Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77423
| From | Dave Angel <davea@davea.name> |
|---|---|
| Subject | Re:error while writing program to send mail. |
| Date | 2014-09-01 20:02 -0400 |
| Organization | news.gmane.org |
| References | <540502CD.8030209@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13702.1409616038.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re:error while writing program to send mail. Dave Angel <davea@davea.name> - 2014-09-01 20:02 -0400
csiph-web