running python script running the sendmail program the open source sendmail program offers another way to initiate mail from program assuming it is installed and configured on your systemyou can launch it using python tools like the os popen call of the previous paragraph using the standard smtplib python module python' standard library comes with support for the client-side interface to smtp--the simple mail transfer protocol-- higher-level internet standard for sending mail over sockets like the poplib module we met in the previous sectionsmtplib hides all the socket and protocol details and can be used to send mail on any machine with python and suitable socket-based internet link fetching and using third-party packages and tools other tools in the open source library provide higher-level mail handling packages for pythonmost build upon one of the prior three techniques of these four optionssmtplib is by far the most portable and direct using os popen to spawn mail program usually works on unix-like platforms onlynot on windows (it assumes command-line mail program)and requires spawning one or more processes along the way and although the sendmail program is powerfulit is also somewhat unix-biasedcomplexand may not be installed even on all unix-like machines by contrastthe smtplib module works on any machine that has python and an internet link that supports smtp accessincluding unixlinuxmacand windows it sends mail over sockets in-processinstead of starting other programs to do the work moreoversmtp affords us much control over the formatting and routing of email smtp mail sender script since smtp is arguably the best option for sending mail from python scriptlet' explore simple mailing program that illustrates its interfaces the python script shown in example - is intended to be used from an interactive command lineit reads new mail message from the user and sends the new mail by smtp using python' smtplib module example - pp \internet\email\smtpmail py #!/usr/local/bin/python ""##########################################################################use the python smtp mail interface module to send email messagesthis is just simple one-shot send script--see pymailpymailguiand pymailcgi for clients with more user interaction featuresalso see popmail py for script that retrieves mailand the mailtools pkg for attachments and formatting with the standard library email package##########################################################################""smtpsending email