def sendmail(from_address, to_address, subject, message, headers=None, **kw):
 attachments = kw.pop('attachments', [])
 mail = _EmailMessage(from_address, to_address, subject, message, headers, **kw)
 for a in attachments:
  if isinstance(a, dict):
   mail.attach(a['filename'], a['content'], a.get('content_type'))
  elif hasattr(a, 'read'):
   filename = os.path.basename(getattr(a, 'name', ''))
   content_type = getattr(a, 'content_type', None)
   mail.attach(filename, a.read(), content_type)
  elif isinstance(a, basestring):
   f = open(a, 'rb')
   content = f.read()
   f.close()
   filename = os.path.basename(a)
   mail.attach(filename, content, None)
  else:
   raise ValueError(('Invalid attachment: %s' % repr(a)))
 mail.send()

def sendmail ( from_address , to_address , subject , message , headers = None , ** kw ) : attachments = kw . pop ( 'attachments' , [ ] ) mail = _EmailMessage ( from_address , to_address , subject , message , headers , ** kw ) for a in attachments : if isinstance ( a , dict ) : mail . attach ( a [ 'filename' ] , a [ 'content' ] , a . get ( 'content_type' ) ) elif hasattr ( a , 'read' ) : filename = os . path . basename ( getattr ( a , 'name' , '' ) ) content_type = getattr ( a , 'content_type' , None ) mail . attach ( filename , a . read ( ) , content_type ) elif isinstance ( a , basestring ) : f = open ( a , 'rb' ) content = f . read ( ) f . close ( ) filename = os . path . basename ( a ) mail . attach ( filename , content , None ) else : raise ValueError ( ( 'Invalid attachment: %s' % repr ( a ) ) ) mail . send ( )
sends the email message message with mail and envelope headers for from from_address_ to to_address with subject .