ssmtp is a send-only sendmail emulator for machines which normally pick their mail
up from a centralized mailhub (via pop, imap, nfs mounts or other means). It pro-
vides the functionality required for humans and programs to send mail via the
standard or /usr/bin/mail user agents.

It accepts a mail stream on standard input with recipients specified on the com-
mand line and synchronously forwards the message to the mail transfer agent of a
mailhub for the mailhub MTA to process. Failed messages are placed in dead.letter
in the sender's home directory.

Config files allow one to specify the address to receive mail from root, daemon,
etc.; a default mailhub; a default domain to be used in From: lines; and per-user
From: addresses and mailhub names.

It does not attempt to provide all the functionality of sendmail: it is intended
for use where other programs are the primary means of at last mail delivery. It
is usefull with pop/imap, or to simulate the Sun shared mail spool option for non-
Sun machines, for machines whose sendmails are too difficult (or various) to con-
figure, for machines with known disfeatures in their sendmails or for ones where
there are ``mysterious problems''.

It does not do aliasing, which must be done either in the user agent or on the
mailhub. Nor does it honor .forwards, which have to be done on the recieving host.
It especially does not deliver to pipelines.

Starting:

Code:

# emerge ssmtp
# cd /etc/ssmtp

To make things look better when you recive emails from root you can edit root's name to something else. However this is completely optional and not needed to make ssmtp work properly.

Code:

# nano /etc/passwd

and change:

Code:

root:x:0:0:root:/root:/bin/bash

to:

Code:

root:x:0:0:admin:/root:/bin/bash

or simply do:

Code:

# usermod -c 'admin' root

In the following example i will be using rogers.com info to demonstrate how to setup ssmpt
Now lets edit ssmtp.conf.

Code:

# nano /etc/ssmtp.conf

Code:

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.

# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=<root@email.address>

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
# This should be your remote smtp email server info

# with the following example all emails sent from root; when recived
# will show in the from line: From: admin <gentoo@freethinker.net>
# in this case <gentoo> is the box name in /etc/conf.d/hostname
# and <freethinker.net> the domainame in /etc/resolve.conf

root:gentoo@freethinker.net:smtp.broadband.rogers.com

# if a regular user sends an email without a costumized format then
# then the from line would show: From: john@smtp.broadband.rogers.com

# if you wish to have your own regular user sending emails with a better
# looking format like root has, then add something like this for each other user

jack:jack@freethinker.net:smtp.broadband.rogers.com

# what ever you put here <:jack@freethinker.net:> can be costumized
# by your own taste. For a regular user there is no need to change
# anything in /etc/passwd

Testing:

Code:

# mail -s "testing ssmtp" someguy@some-isp.com
- press enter and you can type whatever you wish as the message body
- press enter and then ctrl+D
- press enter again and the email should be sent
- check your remote mailbox

I was reviewing the "unanswered posts" list on this forum. The funny thing is the next item on my to-do list, after answering at least one "unanswered post" was, indeed, searching for info about sSMTP configuration on Gentoo Linux. After answering my first post I saw your HOWTO.

I've searched for mail, and it's not on my machine.
> find / -name mail_________________"The problem with the world is that fools and fanatics are always so sure of themselves while wiser people are so full of doubt."
- Bertrand Russell

Here I'm using mail-mta/ssmtp-2.61 and I've got no mail command; I simply do

Code:

/usr/sbin/sendmail user@isp.tld
Subject:test

Hi! :)

and I terminate the body with ctrl-D.
Btw Blue-Steel, thanks for the howto, I was trying to find a quick way to set it up, bored of the dead.letter file cron kept creating in /root, and your post was perfect

the method
$echo "mail body" | /usr/sbin/sendmail -s "test" someone@gmail.com
and i recive empty letter with no subject.
also tried specify recive data from stdin but has the same effect - none._________________house of mystic lies

Last edited by unaos on Mon May 22, 2006 10:04 pm; edited 1 time in total

you rockz dude! that's the classic "RTFM" example - RFC was the answer. shame for me
and now all is ok with echo -e "Subject: test\n\n the body \n" | /usr/lib/sendmail somebody@isp.net_________________house of mystic lies

I would like to use SSMTP(ssmtp-2.61) to replace the big "sendmail". In order to use "smtp.gmail.com" to send e-mails, it seems need the SSL support. But there are always compile errors after enabling the SSL option(compile ok without enabling SSL). Should I compile SSMTP by using "Debian" OS?(seems miss the " krb5.h" in my Redhat7 system?) Or something wrong in my compiling procedures as below:

I would like to use SSMTP(ssmtp-2.61) to replace the big "sendmail". In order to use "smtp.gmail.com" to send e-mails, it seems need the SSL support. But there are always compile errors after enabling the SSL option(compile ok without enabling SSL). Should I compile SSMTP by using "Debian" OS?(seems miss the " krb5.h" in my Redhat7 system?)

This is a Gentoo forum, so I don't know how much help we'll be able to provide a Redhat system. You probably need to install the devel package for kerberos (kerberos-devel perhaps), assuming of course that krb5.h is part of the kerberos package. You may need to do some googling to determine what package on your system owns krb5.h.

Thanks for your hint about "kerberos". I copied all missing *.h files(not only krb5.h) from /usr/kerberos/include/ in my Redhat9(sorry! not Redhat7) PC. Then, no compile error.

****************************************************

Do you know how to cross-compile SSMTP for MIPS CPU board?
Compile ok after copying the missing *.h files as the above, but link error! The SSL library is missing, I have tried to copy libssl* to my cross-compile directory. But it did not work. The error messages are as below: