How can I send an email from the command line?

Aart Koelewijn aart at mtack.xs4all.nl
Sat Mar 1 14:13:45 UTC 2008


On Fri, 29 Feb 2008 20:42:57 -0500, Neil Cherry wrote:

> mierda tuti wrote:
>> Thank a lot
>> 
>> Something knows about some manual, or url where it's how could I
>> configure it....
>> 
>> 
>> 
>> 2008/2/29, Tom <coffindvm at seisp.com <mailto:coffindvm at seisp.com>>:
>> 
>>     On Fri, Feb 29, 2008 at 11:34:46PM +0100, mierda tuti wrote:
>>      > Hi,
>>      >
>>      > I' trying to cand execute a command in a shell-script to can
>>      > send
>>     a email to
>>      > somewhere out of my LAN.
>>      > I 've seen another post about that but he want to do with
>>      > evolution. I don't have configured Evolution, could I do with
>>      > other program?
>>     I've been
>>      > reeding that I could do with mutt. But I think that I need
>>     install MTA like
>>      > Sendmail. I 've installed sendmail but do I need configure? What
>>      > else I have to do it?
>>      >
>>      > Any help?
>>      >
>>      > Thanks a lot and sorry for my englsih
>> 
>> 
>>     Maybe you could use mailx.
> 
> Assuming that you have the mail sending sub system working you can do
> something like this:
> 
> cmd file | mutt -s "Subject string goes here" someone at somewhere.uucp
> 
> of even redirect a file into mutt with similar options from the command
> line.
> 
> If you'd like to use gmail as your smart host for your mail subsystem
> (sendmail) check this out:
> 
> http://www.linuxha.com/other/sendmail/gmail.html

As I use this on a daily basis, a short example script file:

#!/bin/sh

/usr/bin/mutt -s [subject] -a [attachment] -b [bcc] [sender] < \
[text(file)]

It is as easy as that, man mutt will give further explanations

Aart






More information about the ubuntu-users mailing list