[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [Pygame] Sending E-Mail Through Python



I don't have a module named MIMEText.
This isn't really a pygame question though.
Actually it isn't at all a pygame question.
Unless you're making an email chess game that has a graphical
interface made with pygame or something.
which I doubt.
Anyway,
Cheers!
Wish I could be of more assistance.
By the way, you should make that chess game. that would be cool.
If you don't make it maybe I will.

On Sun, 06 Feb 2005 23:57:41 -0500, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
> Any idea why the e-mail code provided in Python doesn't work for me?
> Running the function below gives me the error: "SMTPServerDisconnected:
> Connection unexpectedly closed." I think the problem is with the server,
> which in the example code just gives "localhost." Changing that to
> "www.xepher.net," my domain name, just hangs the program.
> 
> Kris
> 
> ## e-mail.py
> ## Mostly copied from Python docs (www.python.org).
> 
> # Import smtplib for the actual sending function
> import smtplib
> 
> # Import the email modules we'll need
> from email.MIMEText import MIMEText
> 
> ONLINE = True
> 
> def SendEMail(content, whofrom, to, subject=""):
>      """Send an e-mail."""
> 
>      if not ONLINE:
>          return
> 
>      # Create a text/plain message
>      msg = MIMEText( content )
> 
>      msg['Subject'] = subject
>      msg['From'] = whofrom
>      msg['To'] = to
> 
>      # Send the message via our own SMTP server, but don't include the
>      # envelope header.
>      s = smtplib.SMTP("localhost")
>      s.connect()
>      s.sendmail(whofrom, [to], msg.as_string())
>      s.close()
> 
>