send mail from shell on 8.04 server (how to?)

Amedee Van Gasse (ub) amedee-ubuntu at amedee.be
Wed Oct 14 08:03:29 UTC 2009


On Mon, October 12, 2009 17:53, Nik N wrote:
> I have an 8.4 server behind a router which *is not* configured as a
> mail server. Specifically, I don't want to install postfix/sendmail or
> anything that runs as a service and likely impacts the security of the
> box.
>
> How do I send an e-mail message from shell? Ideally, it would be something
> like:
>
> sendMyMsg -s Test -r somedude at somedomain.com -t "Hello dude!" -m
> mail.myisp.com
>
> (Where -s is subject, -r recipient, -t text and -m the outgoing smtp
> server).

I can't help you directly, but I am able to send email with only a telnet
client:

telnet mail.myisp.com 25
EHLO myhostname
MAIL FROM:<me at myisp.com>
RCPT TO:<somedude at somedomain.com>
DATA
From: <spoofedfrom at otherdomain.com>
Subject: This is the subject
X-Whatever-Header: you can define your own mailheaders

This is the body of the message.
You end it with a dot on a single line.
Like this:

.

QUIT



Google for "telnet send email" for more details.
If you could script this in some way, then you would essentially have
written your very own very basic MTA. It wouldn't have any error handling
or other useful features so I still advise you to look for a
(non-daemonized) MTA. I often use the telnet method as a proof-of-concept,
or for debugging purposes.

HTH, HAND
-- 
Amedee





More information about the ubuntu-users mailing list