<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.26.3">
</HEAD>
<BODY>
On Mon, 2010-04-05 at 23:18 -0700, Agile Aspect wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
On Wed, Mar 31, 2010 at 9:04 PM, Fajar Priyanto <<A HREF="mailto:fajarpri@arinet.org">fajarpri@arinet.org</A>> 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
> <A HREF="mailto:CentOS@centos.org">CentOS@centos.org</A>
> <A HREF="http://lists.centos.org/mailman/listinfo/centos">http://lists.centos.org/mailman/listinfo/centos</A>
>

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()


</PRE>
</BLOCKQUOTE>
<BR>
why not just 'export smtp=someserver.com:25' and then using 'mail' command?<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<BR>
<BR>
Calin<BR>
<BR>
Key fingerprint = 37B8 0DA5 9B2A 8554 FB2B 4145 5DC1 15DD A3EF E857<BR>
<BR>
=================================================<BR>
We have more to fear from the bungling of the incompetent than from the machinations of the wicked.
</TD>
</TR>
</TABLE>
</BODY>
</HTML>