SMTP host name


Examples (Python)

SMS sending

import smtplib
smtpserver = 'mail01'

mssg = 'Hello world'

session = smtplib.SMTP(smtpserver)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)

if smtpresult:
    errstr = ""
    for recip in smtpresult.keys():
        errstr = """Could not delivery mail to: %s

Server said: %s

%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
    raise smtplib.SMTPException, errstr

File attachement

import sys, smtplib, MimeWriter, base64, StringIO

message = StringIO.StringIO()
writer = MimeWriter.MimeWriter(message)
writer.addheader('Subject', 'Test message')

# start off with a text/plain part
part = writer.nextpart()
body = part.startbody('text/plain')
body.write('This is a test, enjoy :)')

# now add an image part
#part = writer.nextpart()
#part.addheader('Content-Transfer-Encoding', 'base64')
#body = part.startbody('image/jpeg')
#base64.encode(open('kitten.jpg', 'rb'), body)

# finish off

# send the mail
smtp = smtplib.SMTP('mail01')
smtp.sendmail('', '', message.getvalue())

-- SashaMazurov - 27 Sep 2007

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2007-09-27 - SashaMazurov
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback