On Mon, 2010-04-05 at 23:18 -0700, Agile Aspect wrote: > On Wed, Mar 31, 2010 at 9:04 PM, Fajar Priyanto <fajarpri at arinet.org> wrote: > > Hi all, > > Is it possible to send mail from CLI (bash, python) without any LOCAL > > SMTP installed, using SMTP on another machine. > > Care to give a glimpse of the code? > > Thank you. > > _______________________________________________ > > CentOS mailing list > > CentOS at centos.org > > http://lists.centos.org/mailman/listinfo/centos > > > > The enclosed script works for python 2.5 (it's an example.) > > If you don't use the localhost sendmail, then you'll have to relay > through another sendmail server - and good luck with that. > > Maybe you can relay through a Google? > > ;----------------------------------------------------------; > > #!/usr/bin/env python > > import smtplib > > def prompt(prompt): > return raw_input(prompt).strip() > > fromaddr = prompt("From: ") > toaddrs = prompt("To: ").split() > print "Enter message, end with ^D (Unix) or ^Z (Windows):" > > # Add the From: and To: headers at the start! > msg = ("From: %s\r\nTo: %s\r\n\r\n" > % (fromaddr, ", ".join(toaddrs))) > while 1: > try: > line = raw_input() > except EOFError: > break > if not line: > break > msg = msg + line > > print "Message length is " + repr(len(msg)) > > server = smtplib.SMTP('localhost') > server.set_debuglevel(1) > server.sendmail(fromaddr, toaddrs, msg) > server.quit() > > why not just 'export smtp=someserver.com:25' and then using 'mail' command? Calin Key fingerprint = 37B8 0DA5 9B2A 8554 FB2B 4145 5DC1 15DD A3EF E857 ================================================= We have more to fear from the bungling of the incompetent than from the machinations of the wicked. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.centos.org/pipermail/centos/attachments/20100406/46bf40cc/attachment-0005.html>