File: email_test.py

package info (click to toggle)
python-pyflow 1.1.20-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 996 kB
  • sloc: python: 4,154; sh: 219; ansic: 15; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
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

import smtplib
from email.MIMEText import MIMEText

def getHostName() :
    import socket
    #return socket.gethostbyaddr(socket.gethostname())[0]
    return socket.getfqdn()

def getDomainName() :
    "maybe this isn't the technical term -- this is just the hostname - the host"
    hn=getHostName().split(".")
    if len(hn)>1 : hn=hn[1:]
    return ".".join(hn)


me = "pyflow-bot@"+getDomainName()
to = "csaunders@illumina.com"

msg=MIMEText("foo foo")
msg["Subject"] = "pyFlow: job: XXX complete"
msg["From"] = me 
msg["To"] =  to

msg.as_string()

s=smtplib.SMTP('localhost')
s.sendmail(me,to,msg.as_string())
s.quit()