Joon's blog

Python | openSUSE | LaTeX

Archive for the ‘python’ Category

openSUSE 11.4: Installation of IPython 0.11.dev

without comments

Successful with openSUSE 11.4 x64 and IPython 0.11.dev

1. download

git clone git://github.com/ipython/ipython.git

2. dependencies

libzmq0
pyzmq

IPython 0.11.dev needs newer version of pyzmq than the one in the openSUSE repos.
You can install it with easy_install:

sudo easy_install pyzmq

If it fails because of libzmq0 version, then force the pyzmq version to be 2.0.10.1:

sudo easy_install pyzmq==2.0.10.1

3. compile & Install

sudo python setup.py install

Written by joon

May 12th, 2011 at 4:48 pm

Python Script: Send email using GMail SMTP

without comments

Here is a Python script which uses Gmail SMTP to send an email.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# Gmail SMTP script by joon
# Snippets from the following codes were used:
#  http://www.go4expert.com/forums/showthread.php?t=7567
#  http://docs.python.org/library/email-examples.html?highlight=sendmail
#  http://djkaos.wordpress.com/2009/04/08/python-gmail-smtp-send-email-script/
import smtplib
from email.mime.text import MIMEText
sender = 'sender@gmail.com'
recipients = 'toEmailAddress'
msg = MIMEText('Email Contents')
msg['Subject'] =  'Email Subject'
msg['From'] = sender
msg['To'] = recipients
smtpserver = 'smtp.gmail.com'
smtpuser = 'ID'         # set SMTP username here
smtppass = 'Password'   # set SMTP password here
session = smtplib.SMTP("smtp.gmail.com", 587)
session.ehlo()
session.starttls()
session.ehlo()
session.login(smtpuser, smtppass)
smtpresult = session.sendmail(sender, [recipients], msg.as_string())
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
session.close()

Written by joon

July 22nd, 2009 at 3:21 pm

Posted in python

Tagged with , , , , ,