Good grief! And they call a 722-line program "simple"?! LOL! I did what I need to do with a __one_line_shell_script__ LOL! Naw, if I have to go through all that, I'll skip on python this time around, thank you very much! Eric
>From: hlubenow <[EMAIL PROTECTED]> >To: python-list@python.org >Subject: Re: Can't Get Email Interface Working >Date: Sat, 07 Apr 2007 17:33:38 +0200 > >Eric Price wrote: > > > Hi; > > I'm writing a script that includes an email function. So I went to the > > cookbook and dug up this, and tweaked it just a bit to make it easier to > > get it to work, but it throws an error: > > > >>>>def createMail(sender, recipient, subject, html, text): > > ... import MimeWriter, mimetools, cStringIO > > ... out = cStringIO.StringIO() > > ... # txtin = cStringIO.StringIO(msg) > > ... writer = MimeWriter.MimeWriter(out) > > ... writer.addheader("From", sender) > > ... writer.addheader("To", recipient) > > ... writer.addheader("Subject", subject) > > ... writer.addheader("MIME-Version", "1.0") > > ... writer.startmultipartbody("alternative") > > ... writer.flushheaders() > > ... subpart = writer.nextpart() > > ... subpart.addheader("Content-Transfer-Encoding", >"quoted-printable") > > ... pout = subpart.startbody("text/plain", [("charset", >'us-ascii')]) > > ... mimetools.encode(txtin, pout, 'quoted-printable') > > ... txtin.close() > > ... subpart = writer.nextpart() > > ... subpart.addheader("Content-Transfer-Encoding", >"quoted-printable") > > ... pout = subpart.startbody("text/html", [("charset", 'us-ascii')]) > > ... mimetools.encode(htmlin, pout, 'quoted-printable') > > ... htmlin.close() > > ... writer.lastpart() > > ... msg = "test" > > ... out.close() > > ... return msg > > ... > >>>># --------------------------------------------------------------- > > ... def sendMail(sender, recipient, subject, html, text): > > ... import smtplib > > ... message = createMail(sender, recipient, subject, html, text) > > ... server = smtplib.SMTP("localhost") > > ... server.sendmail(sender, recipient, message) > > ... server.quit() > > ... > >>>>if __name__=="__main__": > > ... sendMail("[EMAIL PROTECTED]", "[EMAIL PROTECTED]", "Web Stie(s) > > Down!!!", "", "text") > > ... > > Traceback (most recent call last): > > File "<stdin>", line 2, in ? > > File "<stdin>", line 4, in sendMail > > File "<stdin>", line 10, in createMail > > File "/usr/local/lib/python2.4/MimeWriter.py", line 153, in > > startmultipartbody > > self._boundary = boundary or mimetools.choose_boundary() > > File "/usr/local/lib/python2.4/mimetools.py", line 130, in > > choose_boundary > > hostid = socket.gethostbyname(socket.gethostname()) > > socket.gaierror: (8, 'hostname nor servname provided, or not known') > >>>> > > > > Now, I can send email from my server no problem. In fact, I have my >script > > working already...but with a shell script instead of this python code. > >:lol: > > > Please advise. > > TIA, > > Eric > >You may want to take a look at simplemail.py: > >http://gelb.bcom.at/trac/simplemail/browser/trunk/simplemail.py > >that does sending mails in Python comfortably. > >HTH > >H. >-- >http://mail.python.org/mailman/listinfo/python-list _________________________________________________________________ Interest Rates Fall Again! $430,000 Mortgage for $1,399/mo - Calculate new payment http://www.lowermybills.com/lre/index.jsp?sourceid=lmb-9632-18679&moid=7581 -- http://mail.python.org/mailman/listinfo/python-list