Newbie here with a (hopefully not) dumb question....tri ed searching around on the 'Net without success, so here goes....
I have been playing around with python. I wrote a script that sends an smtp email. Here is the link that I found explaining how such a script could be written Sending an Email
As you see it imports a module as follows: "import smtplib".
I am using a linux machine (ubuntu ditro). It has both python2.5 and python2.4 installed. I also have wxpython installed.
Here is the script:
From the terminal, the script works fine. I then played around with tkinter, and I got the script to work from a GUI as well.
However, I then tried playing around with wxpython and when I tried to send the email thru the wxpython created GUI, I get the following error message:
I have looked around in my /usr/lib directory, and there is an smtplib in a python2.4 directory and one in the python2.5 directory.
I tried changing:
to
In both the above script and the GUI scripts. Result is the same, so I changed it to:
With the result that the wxpython script tells me:
Why am I getting this error in wxpython, but not tkinter and the terminal?
I have been playing around with python. I wrote a script that sends an smtp email. Here is the link that I found explaining how such a script could be written Sending an Email
As you see it imports a module as follows: "import smtplib".
I am using a linux machine (ubuntu ditro). It has both python2.5 and python2.4 installed. I also have wxpython installed.
Here is the script:
Code:
#! /usr/bin/env python def Email_func (Mess): import smtplib HeaderFile = '/home/***.***' Header = open(HeaderFile, 'r') MyAddress = Header.readline() OppAddress = Header.readline() Subject = Header.readline() EmailFull = ''.join([MyAddress, OppAddress, Subject, Mess]) # smtp sever settings smtpserver = 'mydomain.com' AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1 smtpuser = 'myname@mydomain.com' # for SMTP AUTH, set SMTP username here smtppass = '****' # for SMTP AUTH, set SMTP password here # creating email address settings RECIPIENTS = [OppAddress, MyAddress] SENDER = MyAddress # sending email session = smtplib.SMTP(smtpserver) if AUTHREQUIRED: session.login(smtpuser, smtppass) print "Email successfully sent!" smtpresult = session.sendmail(SENDER, RECIPIENTS, EmailFull) if smtpresult: errstr = "" for recip in smtpresult.keys(): errstr = """Could not delivery mail to: %s Server said: %s %s %s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr) raise smtplib.SMTPException, errstr
However, I then tried playing around with wxpython and when I tried to send the email thru the wxpython created GUI, I get the following error message:
Traceback (most recent call last):
File "/home/***/python_scripts/glade/email.py", line 40, in save
SendGame_func.E mailGame(self.t ext_ctrl_1.GetV alue())
File "/home/****/python_scripts/glade/SendGame_func.p y", line 5, in EmailGame
import smtplib
File "/usr/lib/python2.4/smtplib.py", line 49, in ?
from email.base64MIM E import encode as encode_base64
ImportError: No module named base64MIME
File "/home/***/python_scripts/glade/email.py", line 40, in save
SendGame_func.E mailGame(self.t ext_ctrl_1.GetV alue())
File "/home/****/python_scripts/glade/SendGame_func.p y", line 5, in EmailGame
import smtplib
File "/usr/lib/python2.4/smtplib.py", line 49, in ?
from email.base64MIM E import encode as encode_base64
ImportError: No module named base64MIME
I tried changing:
#! /usr/bin/env python
#! /usr/bin/python2.4
#! /usr/bin/python2.5
Traceback (most recent call last):
File "/home/****/python_scripts/glade/email.py", line 5, in <module>
import wx
ImportError: No module named wx
File "/home/****/python_scripts/glade/email.py", line 5, in <module>
import wx
ImportError: No module named wx
Comment