# using ssmtp for cron

## schmutzfinger

I am working on the setup for ssmtp for a while now. And it seems to me, that this tool is not as simple as the dev's tell us.

First of all i don't know if i understand the ssmtp.conf.

 *Quote:*   

> 
> 
> # Where will the mail seem to come from?
> 
> rewriteDomain=mydomain.de
> ...

 

actually this line causes

```

root@myhostname# echo hello | mailto -s "hello" root

```

to send the mail to root@mydomain.de. And this is exactly the other way around I would expect from the comment.

After realising that I changed the configfile to this

 *Quote:*   

> 
> 
> ssmtp.conf
> 
> -------
> ...

 

now the sendmail command would send a mail with

FROM=  root@myhostname

TO= root@isp.de

ENVELOPE_TO= MyLocalLogin@isp.de

that means that MyLocalLogin@isp.de is the only one who will actually get the mail, but the TO field is wrong. I checked this and it works fine, so root@isp.de will not read your mail to your local root account. With this configuration i can send mails via sendmail from root and my user account over the mailhub of the isp.

But using "echo hello" as the input of the pipe does not realy take time so I didn't see another problem of this setup. Cron kept on writing /root/dead.letter and I finally figured out why. On my machine the logs said

```

/var/log/mail

  Mar  1 12:38:59 [sSMTP] Connection lost in middle of processing

/var/log/crond

  Mar  1 12:48:04 [/usr/sbin/cron] (root) MAIL (mailed 7915 bytes of output but got status 0x0001_)

```

this is what mail.isp.de has in its logs

```

2005-03-01 12:38:59 1D65dX-0005dS-00 SMTP data timeout (message abandoned) on connection from myhostname.isp.de

(myhostname.isp.de) [xxx.xxx.xxx.xxx]

```

It seems to me that this ssmtp already opens the connection to the mailserver when the process in front of the pipe starts. When this process takes more than the timeout time of the mailhub your mail will end up in dead.letter, and my cron jobs usually take a while.

Please tell me if you are using ssmtp to send your local mail through your isp. I don't know what i did wrong wrong here. 

I think ssmtp is really bad documented and should not be the default MTA for a great distri like gentoo. I did not find one single thread where one used this tool sucessfully and could tell how he did it. Please don't tell me to use a real MTA. I wanted to give it a try because the dev's say it would be so easy and its default for gentoo.

----------

## maguire

Thanks schmutzfinger!

I was having the same problem with cron output not being e-mailed, but rather ending-up in a "dead.letter" file.  I couldn't figure-out what was causing the problem 'til I saw your post...  Sure enough, I have the "connection lost" message in my mail log too!

'ssmtp' is working fine for my normal e-mail needs, but this 'cron' issue is not insignificant!  Personally, I didn't *want* to install a full-blown MTA on my workstation---because all my mail goes out to a mail server and I uses POP3 to retrieve it, but I *did* want the ability to send e-mail from scripts, etc.

I'm going to try having my long-running 'cron' scripts write output to a temp file, and then e-mail that file within the script itself, which then means I can direct all output of the 'cron' line to /dev/null.  If that works, I'll be satisfied, because I usually only want the 'cron' output while I'm debugging a long-running-in-the-middle-of-the-night process.

Thanks for the information!

Bruce.

----------

