method establishes connection to serverbut the smtp object calls this method automatically if the mail server name is passed in this way failed server sendmail(fromtostextcall the smtp object' sendmail methodpassing in the sender addressone or more recipient addressesand the raw text of the message itself with as many standard mail header lines as you care to provide when you're donebe sure to call the object' quit method to disconnect from the server and finalize the transaction notice thaton failurethe sendmail method may either raise an exception or return list of the recipient addresses that failedthe script handles the latter case itself but lets exceptions kill the script with python error message subtlycalling the server object' quit method after sendmail raises an exception may or may not work as expected--quit can actually hang until server timeout if the send fails internally and leaves the interface in an unexpected state for instancethis can occur on unicode encoding errors when translating the outgoing mail to bytes per the ascii scheme (the rset reset request hangs in this casetooan alternative close method simply closes the client' sockets without attempting to send quit command to the serverquit calls close internally as last step (assuming the quit command can be sent!for advanced usagesmtp objects provide additional calls not used in this exampleserver login(userpasswordprovides an interface to smtp servers that require and support authenticationwatch for this call to appear as an option in the mail tools package example later in this server starttls([keyfile[certfile]]puts the smtp connection in transport layer security (tlsmodeall commands will be encrypted using the python ssl module' socket wrapper ssl supportand they assume the server supports this mode see the python library manual for more on these and other calls not covered here sending messages let' ship few messages across the world the smtpmail script is one-shot tooleach run allows you to send single new mail message like most of the client-side tools in this it can be run from any computer with python and an internet link that supports smtp (most dothough some public access machines may restrict users to http [webaccess only or require special server smtp configurationhere it is running on windowsc:\pp \internet\emailsmtpmail py fromeric the half bee@yahoo com topp @learning-python com smtpsending email