[X-Unix] mail from terminal
Simon Forster
simon-lists at ldml.com
Thu Apr 21 07:17:10 PDT 2005
On 21 Apr 2005, at 14:30, Ben Gold wrote:
> I'd like to be able to simply send an email from the terminal. How do
> I do this?
>
> Is there a command that can accept all the info? SMTP, etc. Or do I
> need to configure the unix mail program?
python
>>>import smtplib
>>>server = smtplib.SMTP('192.168.0.7')
>>>server.sendmail('from at ldml.com', 'simon-lists at ldml.com', 'Subject:
Some Stuff\n\nHere\'s a test email.')
>>>server.quit()
Works when using an open Sendmail SMTP server within our local network.
A more complete script can be found at
<http://python.fyxm.net/doc/2.4/lib/SMTP-example.html>.
Another server we have requires a POP connection before it'll accept
outgoing mail - so we have a subroutine to do this. In fact it'd be
quite trivial to write a quick Python script which you call from the
command line with 2 arguments - the subject and the message. Better
still write a simple SMTP server into the Python script & then it's all
self contained!
HTH
Simon Forster
_____________________________________________________
LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
Tel: +44 (0)70 9230 5244 Fax: +44 (0)70 9230 5247
_____________________________________________________
More information about the X-Unix
mailing list