how to send a form html by email ?

Gerard Breiner gerard.breiner at ias.u-psud.fr
Tue Mar 18 11:25:27 EST 2003


Hello,
I replaced f1='c\tt' by f1='c:\\tt' and i modified my program as follow :

--------------------------------------
import smtplib
from email.MIMEText import MIMEText

# Import the email modules we'll need
#from email.MIMEText import MIMEText

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
f1='c:\\tt'
fp = open(f1, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % f1
msg['From'] = 'gerard.breiner at ias.u-psud.fr'
msg['To'] = 'gerard.breiner at ias.u-psud.fr'

# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.connect('mailserver.ias.u-psud.fr')
s.sendmail('gerard.breiner at ias.u-psud.fr', ['gerard.breiner at ias.u-psud.fr'],
msg.as_string())
s.close()
------------------------------------------
It work when i run in pythonwin but not inside my navigator.
In my navigator the result is :

-----------------------------------
Mod_python error: "PythonHandler tmail"

Traceback (most recent call last):

  File "C:\Python22\Lib\mod_python\apache.py", line 185, in Dispatch
    object = resolve_object(req, module, object_str, silent)

  File "C:\Python22\Lib\mod_python\apache.py", line 394, in resolve_object
    raise AttributeError, s

AttributeError: module 'c:/program files/apache
group/apache/htdocs/python\tmail.py' contains no 'handler'
-------------------------------------

best regards
gerard


"Gerhard Häring" <gerhard.haering at opus-gmbh.net> a écrit dans le message de
news: slrnb7dshs.9s.gerhard.haering at haering.opus-gmbh.net...
> Gerard Breiner <gerard.breiner at ias.u-psud.fr> wrote:
> > Mod_python error: "PythonHandler tmail"
> >
> > Traceback (most recent call last):
> >
> >   File "C:\Python22\Lib\mod_python\apache.py", line 181, in Dispatch
> >     module = import_module(module_name, _req)
> >
> >   File "C:\Python22\Lib\mod_python\apache.py", line 335, in
import_module
> >     module = imp.load_module(mname, f, p, d)
> >
> >   File "c:/program files/apache group/apache/htdocs/python\tmail.py",
line
> > 10, in ?
> >     # Create a text/plain message
> >
> > IOError: [Errno 2] No such file or directory: 'c:\tt'
> > ---------------------------------------------------
> > however,  'c:\tt' exist  and i defined as :
> > f1='c:\tt'
> > fp = open(f1, 'rb')
> > I wonder whereis the problem ?
>
> Stranger and stranger ...
>
> Note that if you do
>
>     f1='c:\tt'
>
> you're inserting a tab character (\t) after the colon. On Windows to build
> filenames, I'd use one of
>
>     a) f1 = r'c:\tt'
>     b) f1 = 'c:\\tt'
>     c) f1 = 'c:/tt'
>
> The variant in a is called a "raw string". In a raw string, the backslash
> doesn't have any special meaning, while in normal strings, \t, \n, \l and
> maybe other combinations have special meaning (tab, linefeed, page break).
>
> I'm not sure if that's your problem, though.
>
> -- Gerhard






More information about the Python-list mailing list