Ssmtp
From Admin-SIG
ssmtp is an excellent way to send mail through a SMTP relay server. If your machine does not RECEIVE mail, but may need to send it, this is the way to go. This is often the case where there is a central POP or IMAP server where everybody RECEIVES mail, but they may wish to send mail from many machines.
I have the problem where I have application servers that have daemons which send mail, but are not interactive mail users. The main problem I had was that the SMTP server we used was remote (yahoo), and had authentication on its outgoing SMTP connections. The daemons all just sent outgoing e-mail to port 25, no authentication.
ssmtp sets up a symbolic link from sendmail to ssmtp. Unfortunately, AFAIK, there is no way to define the authentication information (username and password) in the ssmtp.conf file. I hope they will change that soon. I tried to write a shell for sendmail that provided this, but It would only work for the root user. I don't know why. I tried everything.
Eventually, I wrote a little c-wrapper called sendmail that would provide the secret username and password arguments to ssmtp which could then send mail through the authenticated SMTP server.
/* Forwards sendmail calls to ssmtp, but adds hard-coded
authentication info for stupid yahoo server
Must compile with -DUSER="-auYahooUserName"
and -DPASSWORD="-apYahooPassword"
*/
#ifndef USER
#define USER "-auMyUserName@bizmail.yahoo.com"
#endif
#ifndef PASSWORD
#define PASSWORD "-apNoneOfYourBusiness"
#endif
#include <unistd.h>
int main(int argc, char *argv[])
{
char *ssmtpArgv[32];
int i;
ssmtpArgv[0] = "/usr/sbin/ssmtp";
/* Add yahoo authentication args for ssmtp */
ssmtpArgv[1] = "-amCRAM-MD5"; /* or -amLOGIN */
ssmtpArgv[2] = USER;
ssmtpArgv[3] = PASSWORD;
for (i=1;i<argc;i++)
ssmtpArgv[i+3] = argv[i]; /* copy over sendmail args */
ssmtpArgv[argc+3] = 0;
return(execv(ssmtpArgv[0],ssmtpArgv));
}

